You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.8 KiB

date title author tags
2019-07-17T00:00:00+01:00 Kubernetes-Rancher CI/CD Pipeline jochum
My Blog

Today I moved my blog from a lxd hosting to our Kubernetes -dev Cluster at the Webmeisterei.

We have our own Gitlab so and we run our own registry on the -dev Cluster, I thought it will be easy to do so but it wasn't that easy and I lost about 8 Hours until I found out that had to open the required Ports on the Firewall :).

See this works.

Tools in use

The Docker Container

I use a multi-stage build to generate the page in a container and serve a copy of the page after in a nginx container.

See this Dockerfile

# Build public with hugo
FROM jguyomard/hugo-builder:latest

COPY . /build

WORKDIR /build

RUN hugo -b -v -t persona

# Copy to a nginx container
FROM nginx:1.17-alpine

COPY docker/nginx/nginx.conf /etc/nginx/
COPY docker/nginx/default.conf /etc/nginx/conf.d/

# This is important "COPY --from=0" line where --from=0 means copy from the first container.
COPY --from=0 /build/public /var/www/

The Deployment

With lots of try-and-error testing I got this deployment.yaml together.

Its important that you have to add the registry to your Project first, in this case

And the pipeline itself

The last step after the container and the deployment was to create a .rancher-pipeline.yml in my repo, I used Rancher -> Cluster dev -> Project -> Workloads -> Pipelines to generate it.

- name: Build
  - publishImageConfig:
      dockerfilePath: ./Dockerfile
      buildContext: .
      tag: pcdummy/renejochumsat:latest
      pushRemote: true
- name: Deploy
  - applyYamlConfig:
      path: ./deployment.yaml
timeout: 60
  - recipient:
    notifier: local:n-mtzwd
  - Success
  - Changed
  - Failed

If it doesn't trigger

Look at this if it doesn't trigger your build.