- High-Level Flow
- Dependencies
- Running Smoke tests
- Suggested Component Directory Structure and Local Development Workflow
Table of contents generated with markdown-toc
In the component repo (e.g. capi-k8s-release
, uaa
, cf-k8s-networking
, etc. ):
- make changes and create a new Docker image
- tell your local copy of
cf-for-k8s
to use that new image by updating the image reference - test that these changes integrate well (i.e. deploy and run smoke tests)
- make a PR to the component repo following its contributions guidelines
(See a suggested local development workflow, below)
Once the component PR has been merged, in cf-for-k8s
repo:
- checkout
develop
and create a new branch- If you do not have access to creating branches and believe you should, please inquire in the #cf-for-k8s slack channel
- Otherwise please submit changes from a fork
- If you are adding/updating data values (i.e.
config/values.yml
), please also add those changes to thesample-cf-install-values.yml
file - tell
vendir
about the change by updating theref:
invendir.yml
to the new commit SHA - synchronize relevant files from the component repo by running
vendir sync
- commit these changes and push to the branch
- submit a PR to
cf-for-k8s
- it should contain changes to
vendir.yml
,vendir.lock.yml
, and the template config changes fromvendir sync
- it should contain changes to
- vendir v0.8.0+ (includes the
directory
flag, used in the development workflow)
-
Deploy your instance of cf-for-k8s.
-
Configure the smoke test environment variables as suggested, below
export SYSTEM_DOMAIN=<your system domain> export SMOKE_TEST_PASSWORD=<CF Admin password from `cf-values.yml`>
-
Run the smoke test suite
cd tests/smoke export SMOKE_TEST_API_ENDPOINT=api.${SYSTEM_DOMAIN} export SMOKE_TEST_USERNAME=admin export SMOKE_TEST_APPS_DOMAIN=apps.${SYSTEM_DOMAIN} export SMOKE_TEST_SKIP_SSL=true ginkgo -v -r ./
In addition to the dependencies above, the workflow below requires these:
To simplify the component development workflow, we recommend repositories organize configuration thusly:
├── example-component
│ ├── config - K8s resources
│ │ ├── deployment.yml
│ │ └── values
│ │ ├── _default.yml - contains schema/defaults for all values used within config
│ │ └── images.yml - contains resolved image references (ideally in digest form)
│ └── build - configuration for the build of CF-for-K8s
│ └── kbld.yml
Notes:
- place all K8s configuration under one directory. e.g.
config/
(so that while invokingytt
you always specify just that one directory.) - within the
config/
directory, gather data value file(s) into a sub-directory: e.g.config/values/
(so that while invokingvendir sync
you always specify just that one directory.) - place anything required to configure building/generating K8s resource templates or data files in a separate directory. e.g.
build
(so that all that's in theconfig
directory are only the K8s resources being contributed to CF-for-K8s)
These instructions assume that you are using the directory structure, above.
-
Create or claim a Kubernetes cluster. We expect these instructions to work for any distribution of Kubernetes, your mileage may vary (local or remote).
-
Checkout
cf-for-k8s
develop and install it to your cluster. -
Start a local Docker Daemon so that you can build (and push) local Docker images.
Here, we install
minikube
for its Docker Daemon (and not necessarily as our target cluster).minikube start eval $(minikube docker-env) docker login -u ...
-
Make changes to your component
-
Rebuild your component image and update any image references in your configuration.
Here, we use
kbld
and generate a ytt data value file (i.e.config/values/images.yml
) with that resolved image reference:cd ~/workspace/example-component cat <(echo "#@data/values"; kbld -f build/kbld.yml --images-annotation=false) \ >config/values/images.yml
Note:
ytt
merges data files in alphabetical order of the full pathname. So,config/values/_default.yml
is used first, THENconfig/values/images.yml
(see k14s/ytt/ytt-data-values). Therefore, it is critical that whatever name you choose for the generated data file (here,images.yml
), it sorts after_default.yml
.Note: see Sample kbld config, below for an example of a
kbld
config. -
Sync your local component configuration into the
cf-for-k8s
repo.Here, we use vendir's
--directory
feature to sync just the directory containing our component:cd ~/workspace/cf-for-k8s vendir sync \ --directory config/_ytt_lib/<path-to-component>=~/workspace/<path-to-component>
For example, sync'ing just CAPI would look like this:
cd ~/workspace/cf-for-k8s vendir sync \ --directory config/_ytt_lib/github.com/cloudfoundry/capi-k8s-release=~/workspace/capi-k8s-release/
-
Re-deploy
cf-for-k8s
with your updated component.
See kbld docs to configure your own kbld.yml
.
Assuming your ytt
template takes the data value at image.example
as the image reference...
images:
example: example-component-image
---
apiVersion: kbld.k14s.io/v1alpha1
kind: Sources
sources:
- image: example-component-image
path: .
---
apiVersion: kbld.k14s.io/v1alpha1
kind: ImageDestinations
destinations:
- image: example-component-image
newImage: docker.io/<your-dockerhub-username>/<your-docker-repo-name>
---
apiVersion: kbld.k14s.io/v1alpha1
kind: ImageKeys
keys:
- example
Where:
- the first YAML document is a "template" into which
kbld
will rewrite the image reference. - the remaining YAML documents are configuration for
kbld
, itself.