Skip to content

Latest commit

 

History

History
151 lines (111 loc) · 4.88 KB

development.md

File metadata and controls

151 lines (111 loc) · 4.88 KB

Development Guide

Table of Contents generated with DocToc

Required tools/Binaries

Multcloud-Operators projects are built with following tools, use following links to get them installed in your env.

Kubernetes:

  • Version 1.13+. Use following link to find an environment or setup one.

Build:

Lint:

Test:

Develop locally

  1. Clone the repository
git clone git@github.com:open-cluster-management/multicloud-operators-subscription.git
cd multicloud-operators-subscription
  1. Login to your hub cluster. Then build the local image
make local
  1. Verify that the image was built successfully. The ls -l build/_output/bin command should return following values
ls -l build/_output/bin 
-rwxr-xr-x  1 user  group  74786048 Jun 14 13:53 appsubsummary
-rwxr-xr-x  1 user  group  60232176 Jun 14 13:53 multicluster-operators-placementrule
-rwxr-xr-x  1 user  group  90153648 Jun 14 13:52 multicluster-operators-subscription
-rwxr-xr-x  1 user  group  52879056 Jun 14 13:52 uninstall-crd
  1. Edit hub subscription pod to make it invalid, this is the prerequisite to start your local image

Find the hub-sub pod

oc get pods -n open-cluster-management | grep hub-sub 
multicluster-operators-hub-subscription-${random-number}  

Edit hub-sub to make it invalid

oc edit pod multicluster-operators-hub-subscription-${random-number} -n open-cluster-management

Search for the image name in the edit mode. Add -invalid to the end of the image name or anything to make it no longer valid. Check the pod status to make it crash (InvalidImageName)

  1. As subscription deployment has many scenarios: deploy to local, deploy to managed clusters, etc. We have four ways to run the image locally.
  • Start subscription manager on hub cluster
export WATCH_NAMESPACE=
export KUBECONFIG=~/.kube/kubeconfig.hub
build/_output/bin/multicluster-operators-subscription --alsologtostderr --sync-interval=60 --v=1 --debug
  • Standalone subscription
export WATCH_NAMESPACE=
export KUBECONFIG=~/.kube/kubeconfig.hub
build/_output/bin/multicluster-operators-subscription --alsologtostderr --standalone --sync-interval=60 --v=1
  • Start subscription manager on local managed cluster (hub cluster is managed cluster)
export WATCH_NAMESPACE=
$ export KUBECONFIG=~/.kube/kubeconfig.hub
build/_output/bin/multicluster-operators-subscription --alsologtostderr --v=1 \
--hub-cluster-configfile=/Users/youruser/.kube/kubeconfig.hub \
--sync-interval=60 \
--cluster-name=local-cluster --debug
  • Start subscription manager on remote managed cluster
export WATCH_NAMESPACE= 
export KUBECONFIG=~/.kube/kubeconfig.managed
build/_output/bin/multicluster-operators-subscription --alsologtostderr --v=1 \
--hub-cluster-configfile=/Users/philipwu/.kube/kubeconfig.hub \
--sync-interval=60 \
--cluster-name=managed-cluster-1 \
--cluster-namespace=managed-cluster-1 

Launch Dev mode

git clone git@github.com:open-cluster-management/multicloud-operators-subscription.git
cd multicloud-operators-subscription
export GITHUB_USER=<github_user>
export GITHUB_TOKEN=<github_token>
make
make build
./build/_output/bin/multicluster-operators-subscription

Build a local image

git clone git@github.com:open-cluster-management/multicloud-operators-subscription.git
cd multicloud-operators-subscription
export GITHUB_USER=<github_user>
export GITHUB_TOKEN=<github_token>
make
make build-images