Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
Shipperctl installs management and application CRDs independently
Browse files Browse the repository at this point in the history
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: #292

Signed-off-by: Oleg Sidorov <[email protected]>
  • Loading branch information
Oleg Sidorov committed Apr 6, 2020
1 parent 6b69e0b commit 2993a74
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion ci/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 20 additions & 8 deletions cmd/shipperctl/cmd/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}

Expand Down

0 comments on commit 2993a74

Please sign in to comment.