Skip to content

Latest commit

 

History

History
124 lines (77 loc) · 4.49 KB

DEVELOPMENT.md

File metadata and controls

124 lines (77 loc) · 4.49 KB

S2I Operator Development Guide

Getting started

  1. Ramp up on kubernetes and CRDs
  2. Checkout your fork
  3. Set up your develop environment
  4. Iterating
  5. Test
  6. Install CRD

Ramp up on kubernetes and CRDs

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.

Checkout your fork

Checkout this repository:

  1. Create your own fork of this repo.

  2. 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

Set up local develop environment

Prerequisites

Also you can install some tools by script install_tools.sh in hack:

./hack/install_tools.sh

Build S2I Operator locally

  1. Set environment variable GO111MODULE=auto , if directory of s2ioperator in your GOPATH, set GO111MODULE=on

  2. 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.

Configure kubectl to use your cluster

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.

Iterating

While iterating on the project, you may need to:

  1. Running unit test and end-to-end to ensure your code are works well.

  2. Update your (external) dependencies with: ./hack/update-vendor.sh

    Also you should running go mod verify to verify dependencies have expected content.

  3. Running make deploy to deploy S2I Operator and verify it's working by looking at the pod logs.

  4. Running make release to release your code, and commit by git.

To make changes to these CRDs, you will probably interact with

Test

Before run test, you shoud install test tools ginkgo by following command:

go get -u  github.com/onsi/ginkgo/ginkgo

Unit tests

Unit tests live side by side with the code they are testing and will run go fmtand go vet before test by default. You can run unit test with:

make test

End to end tests

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

Install S2I CRD

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.