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 fc6e8b3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
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 config use-context kind-app
kubectl -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 fc6e8b3

Please sign in to comment.