|
| 1 | +# Contributing to the Openshift Builder |
| 2 | + |
| 3 | +The OpenShift Builder image drives [OpenShift Builds](https://docs.okd.io/latest/dev_guide/builds/index.html), |
| 4 | +leveraging [Buildah](https://github.com/containers/buildah) and [Source-To-Image](https://github.com/openshift/source-to-image) |
| 5 | +to turn source code into images that can be deployed on Kubernetes. |
| 6 | + |
| 7 | +## Getting the code |
| 8 | + |
| 9 | +To get started, [fork](https://help.github.com/articles/fork-a-repo) the [openshift/builder](https://github.com/openshift/builder) repo. |
| 10 | + |
| 11 | +## Developing |
| 12 | + |
| 13 | +### Testing on an OpenShift Cluster |
| 14 | + |
| 15 | +The easiest way to test your changes is to launch an OpenShift 4.x cluster. |
| 16 | +First, go to [try.openshift.com](https://try.openshift.com) to obtain a pull secret and download the installer. |
| 17 | +Follow the instructions to launch a cluster on AWS. |
| 18 | + |
| 19 | +If you want the latest `openshift-install` and `oc` clients, go to the [openshift-release](https://openshift-release.svc.ci.openshift.org/) |
| 20 | +page, select the channel and build you wish to install, and download the respective `oc` and `openshift-installer` binaries. |
| 21 | +There are three types of channels you can obtain the installer from: |
| 22 | + |
| 23 | +1. `4-stable` - these are stable releases of OpenShift 4, corresponding to GA or beta releases. |
| 24 | +2. `4.x.0-nightly` - nightly development releases, with payloads published to quay.io. |
| 25 | +3. `4.x.0-ci` - bleeding-edge releases published to the OpenShift CI imagestreams. |
| 26 | + |
| 27 | +**Note**: Installs from the `4.x.0-ci` channel require a pull secret to `registry.svc.ci.openshift.org`, which is only available to Red Hat OpenShift developers. |
| 28 | + |
| 29 | +After your cluster is installed, you will need to do the following: |
| 30 | + |
| 31 | +1. Patch the cluster version so that you can launch your own builder image: |
| 32 | + |
| 33 | +``` |
| 34 | +$ oc patch clusterversion/version --patch '{"spec":{"overrides":[{"kind":"ConfigMap", "namespace":"openshift-controller-manager-operator","name":"openshift-controller-manager-images","unmanaged":true}]}}' --type=merge |
| 35 | +``` |
| 36 | + |
| 37 | +2. Make your code changes and build the binary with `make build`. |
| 38 | +3. Build the image using the `Dockerfile.dev` file, giving it a unique tag: |
| 39 | + |
| 40 | +``` |
| 41 | +$ make build-devel-image IMAGE=<MYREPO>/<MYIMAGE> TAG=<MYTAG> |
| 42 | +``` |
| 43 | + |
| 44 | +or if you are using `buildah`: |
| 45 | + |
| 46 | +``` |
| 47 | +$ buildah bud -t <MYREPO>/<MYIMAGE>:<MYTAG> -f Dockerfile.dev . |
| 48 | +``` |
| 49 | + |
| 50 | +4. Push the image to a registry accessible from the cluster (e.g. your repository on quay.io). |
| 51 | +5. Patch the ConfigMap in the override above to instruct the cluster to use your builder image: |
| 52 | + |
| 53 | +``` |
| 54 | +$ oc patch configmap openshift-controller-manager-images -n openshift-controller-manager-operator --patch '{"data":{"builderImage":"<MYREPO>/<MYIMAGE>:<MYTAG>"}}' --type=merge |
| 55 | +``` |
| 56 | + |
| 57 | +6. Watch the openshift controller manager daemonset rollout (this can take a few minutes): |
| 58 | + |
| 59 | +``` |
| 60 | +$ oc get ds controller-manager -n openshift-controller-manager -w |
| 61 | +``` |
| 62 | + |
| 63 | +7. Trigger an OpenShift build via `oc start-build`. You can use one of the templates suggested in `oc new-app` to populate your project with a build. |
| 64 | + |
| 65 | + |
| 66 | +## Submitting a Pull Request |
| 67 | + |
| 68 | +Once you are satisfied with your code changes, you may submit a pull request to the [openshift/builder](https://github.com/openshift/builder) repo. |
| 69 | +A member of the OpenShift Developer Experience team will evaluate your change for approval. |
| 70 | + |
| 71 | +## End-to-End Testing |
| 72 | + |
| 73 | +The OpenShift builder is considered a core component of the OpenShift Container Platform. |
| 74 | +The e2e test suite run against each pull request is located in the [openshift/origin](https://github.com/openshift/origin) repo. |
| 75 | +Tests whose description contains `[Feature:Builds]` are run as part of the e2e suite, and are generally placed in the |
| 76 | +`test/extended/builds` directory. |
| 77 | +Refer to the extended tests [README](https://github.com/openshift/origin/blob/master/test/extended/README.md) |
| 78 | +for instructions on how to develop and run these tests against your own cluster. |
0 commit comments