How to Deploy a Custom Container
It can be useful in many cases to test your code on lower environments before merging it to the mainline. For example, if you have a long-running project that can’t be merged due to breaking changes that need to be accounted for elsewhere, or generally if you want to avoid merging so it can’t be accidentally deployed by another developer before your integration testing is completed.
To do so, you can build a container from your custom code and deploy it to development/staging/UAT/etc. Do not attempt to do this in Production (it should go without saying, and it is probably disallowed anyway).
Prerequisites
- Your app is setup to run in kubernetes the normal way already. See here for a starting point, but there are probably better resources.
- Your have setup Artifactory and Docker in your local development environment.
Steps
- Tag the source code on your git feature branch (use something that makes sense, like “
${NEXT_TAG}-beta.1”. (Consider pushing the tag too.) - Change the version in your local source to match the above (for scala apps, in
version.sbt. Do not commit or push it.) - Build and push the container to our container registry in Artifactory. For scala apps, this means “
sbt dockerBuildAndPush”.- If you get docker push errors like this “
unauthorized: Pushing Docker images with manifest v2 schema 1 to this repository is blocked.” try pushing the image manually with a different manifest format (seedocker push --help). For example: “docker push -f v2s2 docker.artifactory.banno-tools.com/transfer-retrieval:0.678.0-beta.1”
- If you get docker push errors like this “
- Edit the kubernetes deployment to use the new container image you have pushed using “
kubectl”:- The general form is: “
kubectl edit app APP_NAME -n NAMESPACE --context CONTEXT” - For example: “
kubectl edit app transfer-retrieval -n aviato --context uat-centralus-aks” - Note if you find
vidifficult to use, you can change the text editor kubectl uses by setting an environment variable, for example:export KUBE_EDITOR=nanoor more generallyexport EDITOR=nano - When editing, just search for the version number, and update it to be the version you built and pushed.
- The general form is: “
- Watch your k8s deployment update and then have fun testing!