From 1c41ce78c244e83f4b425534e3d76ff9e4b79941 Mon Sep 17 00:00:00 2001 From: Oleg Sidorov Date: Mon, 23 Mar 2020 14:43:29 +0100 Subject: [PATCH] Shipperctl installs management and application CRDs independently Up until now, shipper has been installing CRD objects to management clusters only and this was a part of `shipperctl clusters setup management` command. As we're splitting shipper in management and application components, these components need their own CRDs to operate on the relevant cluster. Therefore, an updated list of CRD groups: * Management - Application - Release - Cluster - RolloutBlock * Application - InstallationTarget - CapacityTarget - TrafficTarget Folow-up to: https://github.com/bookingcom/shipper/pull/292 Signed-off-by: Oleg Sidorov --- Makefile | 2 +- ci/e2e.sh | 8 +++++++- cmd/shipperctl/cmd/clusters.go | 28 ++++++++++++++++++-------- kubernetes/shipper-app.deployment.yaml | 2 +- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 18e89fe35..f7ccca45e 100644 --- a/Makefile +++ b/Makefile @@ -83,7 +83,7 @@ install: install-shipper install-shipper: install-shipper-app install-shipper-mgmt install-shipper-app: build/shipper-app.image.$(IMAGE_TAG) build/shipper-app.deployment.$(IMAGE_TAG).yaml - $(KUBECTL) apply -f build/shipper-app.deployment.$(IMAGE_TAG).yaml + $(KUBECTL) --context $(SHIPPER_CLUSTER) apply -f build/shipper-app.deployment.$(IMAGE_TAG).yaml install-shipper-mgmt: build/shipper-mgmt.image.$(IMAGE_TAG) build/shipper-mgmt.deployment.$(IMAGE_TAG).yaml $(KUBECTL) apply -f build/shipper-mgmt.deployment.$(IMAGE_TAG).yaml diff --git a/ci/e2e.sh b/ci/e2e.sh index 5a0df537a..939535a13 100755 --- a/ci/e2e.sh +++ b/ci/e2e.sh @@ -18,8 +18,14 @@ TEST_STATUS=$? rm -f build/*.latest.yaml # Output all of the logs from the shipper pods, for reference -kubectl -n shipper-system logs $(kubectl -n shipper-system get pod -l component=shipper-app -o jsonpath='{.items[0].metadata.name}') +echo "========================== Management cluster logs ============================" kubectl -n shipper-system logs $(kubectl -n shipper-system get pod -l component=shipper-mgmt -o jsonpath='{.items[0].metadata.name}') +echo "========================== Application cluster logs ===========================" +# It's a shortcut: we hardcode a single app cluster. If we end up running e2e +# tests on multiple app clusters, this should be ran for each of them. +kubectl --context kind-app -n shipper-system get deployment shipper-app -o yaml +kubectl --context kind-app -n shipper-system logs $(kubectl -n shipper-system get pod -l component=shipper-app -o jsonpath='{.items[0].metadata.name}') + # Exit with the exit code we got from the e2e tests exit $TEST_STATUS diff --git a/cmd/shipperctl/cmd/clusters.go b/cmd/shipperctl/cmd/clusters.go index 80b105490..206027d77 100644 --- a/cmd/shipperctl/cmd/clusters.go +++ b/cmd/shipperctl/cmd/clusters.go @@ -152,7 +152,7 @@ func runJoinClustersCommand(cmd *cobra.Command, args []string) error { } func setupManagementCluster(cmd *cobra.Command, configurator *configurator.Cluster) error { - if err := createOrUpdateCrds(cmd, configurator); err != nil { + if err := createOrUpdateManagementCrds(cmd, configurator); err != nil { return err } @@ -192,6 +192,10 @@ func setupManagementCluster(cmd *cobra.Command, configurator *configurator.Clust } func setupApplicationCluster(cmd *cobra.Command, configurator *configurator.Cluster) error { + if err := createOrUpdateApplicationCrds(cmd, configurator); err != nil { + return err + } + if err := createNamespace(cmd, configurator); err != nil { return err } @@ -236,8 +240,8 @@ func joinClusters( return nil } -func createOrUpdateCrds(cmd *cobra.Command, configurator *configurator.Cluster) error { - cmd.Print("Registering or updating custom resource definitions... ") +func createOrUpdateManagementCrds(cmd *cobra.Command, configurator *configurator.Cluster) error { + cmd.Print("Registering or updating management bundle of custom resource definitions... ") if err := configurator.CreateOrUpdateCRD(crds.Application); err != nil { return err } @@ -246,23 +250,31 @@ func createOrUpdateCrds(cmd *cobra.Command, configurator *configurator.Cluster) return err } - if err := configurator.CreateOrUpdateCRD(crds.InstallationTarget); err != nil { + if err := configurator.CreateOrUpdateCRD(crds.Cluster); err != nil { return err } - if err := configurator.CreateOrUpdateCRD(crds.CapacityTarget); err != nil { + if err := configurator.CreateOrUpdateCRD(crds.RolloutBlock); err != nil { return err } - if err := configurator.CreateOrUpdateCRD(crds.TrafficTarget); err != nil { + cmd.Println("done") + + return nil +} + +func createOrUpdateApplicationCrds(cmd *cobra.Command, configurator *configurator.Cluster) error { + cmd.Print("Registering or updating application bundle of custom resource definitions... ") + + if err := configurator.CreateOrUpdateCRD(crds.InstallationTarget); err != nil { return err } - if err := configurator.CreateOrUpdateCRD(crds.Cluster); err != nil { + if err := configurator.CreateOrUpdateCRD(crds.CapacityTarget); err != nil { return err } - if err := configurator.CreateOrUpdateCRD(crds.RolloutBlock); err != nil { + if err := configurator.CreateOrUpdateCRD(crds.TrafficTarget); err != nil { return err } diff --git a/kubernetes/shipper-app.deployment.yaml b/kubernetes/shipper-app.deployment.yaml index 551b0b541..bc52b3ad2 100644 --- a/kubernetes/shipper-app.deployment.yaml +++ b/kubernetes/shipper-app.deployment.yaml @@ -35,4 +35,4 @@ spec: ports: - name: metrics containerPort: 8889 - serviceAccountName: shipper-management-cluster + serviceAccountName: shipper-application-cluster