From 63827cfb13665c3b6305c144835d23c1eec19829 Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Thu, 4 Jul 2019 16:28:04 +0200 Subject: [PATCH] Add installation of plugins and publish as tarball Include a plugins folder for the SiteConfig kustomize plugin. Also refactor make build to publish as a tarball, that will include the plugins and utils folder. Signed-off-by: Yolanda Robla Change-Id: I3fcc3e5acc190ab455c996e4ca2950fabe1bcd43 --- Makefile | 5 +++-- .../kni.akraino.org/v1alpha1/siteconfig/SiteConfig | 23 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 plugins/kustomize/plugin/kni.akraino.org/v1alpha1/siteconfig/SiteConfig diff --git a/Makefile b/Makefile index 0178ca8..1e3476d 100644 --- a/Makefile +++ b/Makefile @@ -43,8 +43,9 @@ binary: @./bin/$(GONAME) binary --bin_path ${BINDIR} --installer_repository ${INSTALLER_GIT_REPO} --installer_tag ${INSTALLER_GIT_TAG} build: - @echo "Building knictl with $(GOPATH) to ./bin" - @GOPATH=$(GOPATH) GOBIN=$(GOBIN) go build -o bin/$(GONAME) $(GOFILES) + @echo "Building knictl with $(GOPATH) to knictl.tar.gz" + @GOPATH=$(GOPATH) GOBIN=$(GOBIN) go build -o $(GONAME) $(GOFILES) + tar -czvf knictl.tar.gz $(GONAME) plugins utils clean: @echo "Destroying previous cluster" diff --git a/plugins/kustomize/plugin/kni.akraino.org/v1alpha1/siteconfig/SiteConfig b/plugins/kustomize/plugin/kni.akraino.org/v1alpha1/siteconfig/SiteConfig new file mode 100755 index 0000000..23e65f0 --- /dev/null +++ b/plugins/kustomize/plugin/kni.akraino.org/v1alpha1/siteconfig/SiteConfig @@ -0,0 +1,23 @@ +#!/bin/bash + +# This is a simple kustomize transformer plugin that allows +# injecting configuration for a site into the blueprint. +# It's current purpose is to inject the pull secret and ssh public key +# into the site config such that it doesn't have to be stored in git iwth the +# blueprint. Instead, it's taken from the WORK_DIR (but could eventually be +# retrieved from a k8s secret or a vault instead). +# The same mechanism could be used in the future to template in more site +# configuration parameters for which a purist "kustomization" is too cumbersome. + +# set -x +set -e + +# Skip the config file name argument. +shift + +PULL_SECRET=$(cat ${HOME}/.kni/pull-secret.json) +SSH_PUB_KEY=$(cat ${HOME}/.kni/id_rsa.pub) + +cat - | sed \ + -e "s|PULL_SECRET|\'${PULL_SECRET}\'|" \ + -e "s|SSH_PUB_KEY|${SSH_PUB_KEY}|" \ No newline at end of file -- 2.16.6