Skip to content

Commit

Permalink
Update readme, switch to ImagePullStrategy: IfNotPresent
Browse files Browse the repository at this point in the history
PullPolicy: Always will not work when testing locally
  • Loading branch information
segfault16 committed Sep 17, 2024
1 parent be71448 commit f445e25
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
41 changes: 41 additions & 0 deletions docker-plain/files/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
# Plain Docker image (docker-plain)

## Purpose

This Quickstarter serves as a minimal starting point for building your own components that don't fit any of the other Quickstarters.
For demonstration purposes, a nginx webserver provides a simple 'Hello World' message.

## Folder structure and important files

- docker: All files inside this folder are available for use in building the docker container
- [docker/Dockerfile](docker/Dockerfile): Defines the container to be built.
- chart: The Helm chart used for deploying the component.
- [chart/Chart.yaml](chart/Chart.yaml): Metadata for your Helm chart.
- [chart/values.yaml](chart/values.yaml): Default values used when templating the Helm chart.
- [chart/values.dev.yaml](chart/values.dev.yaml): Values used for deployment in the 'dev' environment. Values specified in this file are overriding default values from [chart/values.yaml](chart/values.yaml).
- chart/templates:
- [chart/templates/deployment.yaml](chart/templates/deployment.yaml): Template for the [deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) resource. This is where you add additional configuration like environment variables.
- [chart/templates/service.yaml](chart/templates/service.yaml): Template for the [service](https://kubernetes.io/docs/concepts/services-networking/service/) resource.
- [chart/templates/ingress.yaml](chart/templates/ingress.yaml): Template for the [ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/) resource.

## Testing locally

If you want to run this component locally for testing, this might get you started.
It also mimicks what's happening in the [Jenkinsfile](Jenkinsfile).

### Building the container

Using a local container runtime you can build the container and tag it with the current git revision:

```bash
docker build -t testing/my-component:$(git rev-parse --short=8 HEAD) docker/
```

### Deploying the helm chart using

Using a local kubernetes cluster you can deploy the component:

```bash
kubectl create ns docker-plain
kind load docker-image testing/my-component:$(git rev-parse --short=8 HEAD)
helm upgrade --install --wait --atomic --namespace docker-plain --set image.path=testing --set image.name=my-component --set image.tag=$(git rev-parse --short=8 HEAD) docker-plain chart
```

## How to create a custom jenkins-agent out of this docker-plain component
- Remove `odsComponentStageRolloutOpenShiftDeployment(context)` from your `Jenkinsfile`. We only want to build a docker image, not run it outside the pipeline.
- In your `Dockerfile`, replace `FROM alpine:latest` with the ods-jenkins-agent-base image that is available in the OpenDevStack namespace of your cluster, e.g. `FROM docker-registry.default.svc:5000/ods/jenkins-agent-base:latest`.
Expand Down
12 changes: 6 additions & 6 deletions docker-plain/files/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ fullnameOverride: ""
# NOTE: By default image Values are injected from CICD Jenkins pipeline, values defined here are used when not being on CICD Jenkins pipeline context.
# Default values here are provided in case one needs to use the chart without CICD (i.e.: testing the chart).
image:
registry: "docker.io"
path: "nginxinc"
name: "nginx-unprivileged"
tag: "latest"
# You might consider using `IfNotPresent` policy, see https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy
pullPolicy: Always
# registry: "docker.io"
# path: "nginxinc"
# name: "nginx-unprivileged"
# tag: "latest"
# see https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy
pullPolicy: IfNotPresent

## Prefer using ingress over openshift routes
ingress:
Expand Down

0 comments on commit f445e25

Please sign in to comment.