- Ramp up on kubernetes and CRDs
- Checkout your fork
- Set up your develop environment
- Iterating
- Test
- Install CRD
Welcome to the project. S2I Operator are work on Kubernetes, and all steps about ci/cd are defined by CustomResourceDefinitions .Here are some resources helpful to ramp up on some of the technology this project is built on.
- Understanding Kubernetes objects
- API conventions - Types(kinds)
- Extend the Kubernetes API with CustomResourceDefinitions
Checkout this repository:
-
Create your own fork of this repo.
-
Change to your work directory, and clone it
git clone https://github.com/${YOUR_GITHUB_USERNAME}/s2ioperator.git cd s2ioperator git remote add upstream git@github:kubesphere/s2ioperator.git git remote set-url --push upstream no_push
- golang environment
- Kubebuilder 2.0+.
- docker version 17.03+.
- kustomize v3.1.0+
Also you can install some tools by script install_tools.sh
in hack
:
./hack/install_tools.sh
-
Set environment variable
GO111MODULE=auto
, if directory of s2ioperator in yourGOPATH
, setGO111MODULE=on
-
Run the following command to create a binary with the source code:
make manager
If nothing goes wrong, and output a binary in directory WORKDIR/bin/
, mean local environment is ok.
To debug your S2I Operator in local, you will need to Configure kubectl to use your kubernetes cluster.
If you don't have a cluster, please reference Kubernetes doc.
While iterating on the project, you may need to:
-
Running unit test and end-to-end to ensure your code are works well.
-
Update your (external) dependencies with:
./hack/update-vendor.sh
Also you should running
go mod verify
to verify dependencies have expected content. -
Running
make deploy
to deploy S2I Operator and verify it's working by looking at the pod logs. -
Running
make release
to release your code, and commit by git.
To make changes to these CRDs, you will probably interact with
- The CRD type definitions in ./pkg/apis/devops/alpha1
- The reconcilers in ./pkg/controller
- The clients are in ./pkg/client
Before run test, you shoud install test tools ginkgo
by following command:
go get -u github.com/onsi/ginkgo/ginkgo
Unit tests live side by side with the code they are testing and will run go fmt
and go vet
before test by default. You can run unit test with:
make test
By default the tests run against your current kubeconfig context. You can run e2e test with:
make e2e-test
Node: Running End to end tests will change default configs in the directory config
All CustomResourceDefinitions(CRD) used in S2I Operator are defined in config/crds/
. You can use command make manifests
to generate manifests, e.g. CRD, RBAC etc.
Install S2I CRD with following command:
make install-crd
For more information about S2I CRD please to see here.