Skip to content
seed

Getting Started with Rancher and K8s

Sucessful K8s strategy


Specifics of impl

  • package each service into Docker image and put in docker registry
  • Manage each service with a Helm chart, use a command to create a helm chart (look it up online)
    • Important: Chart.yaml (use v2 for apiVersion)
    • Try to keep the version in Chart.yaml consistent with docker version
    • Include configmap.yaml -- this will
    • in values.yaml
      • This is where you specify the list of environment variables (but not add the values for security purposes)
    • On platform pipeline is used to upload Helm chart
      • Upload to the OOR Helm Chart registry
    • IMAGE_LABEL is important for finding
    • Ports are specified in Helm chart through the ingress part of the Helm.
    • For all the settings and access keys for KVS

On rancher development instance - Enter values in Apps & Marketplace > Charts > SERVICE_NAME > edit values and click install

Steps:

  1. Create a docker image
    1. Create a Dockerfile that builds and runs your intended target executable
    2. Use multi stage builds to keep the image small
  2. Upload docker image to registry
  3. Create Chart.yaml, values.yaml (use helm cli documentation to check local dry-run for correct syntax)
    1. Review the Helm docs: https://helm.sh/docs/intro/quickstart/ for how to get started with Charts for a repository.
    2. helm repo add bitnami https://charts.bitnami.com/bitnami
  4. Publish helm chart to helm registry (ideally through CI), after this you can see the chart on the Repo in Rancher
  5. In Rancher update values for Env variables and install, after this you can see the app in the workloads
  6. In Rancher > workload

Troubles

  • Change the ingress host to ``

Using Helm

Helm is a package manager for Kubernetes applications.

Three Big Concepts

Chart is a Helm package. It contains all of the resource definitions necessary to run an application, tool, or service inside of a Kubernetes cluster. Think of it like the Kubernetes equivalent of a Homebrew formula, an Apt dpkg, or a Yum RPM file.

Repository is the place where charts can be collected and shared. It's like Perl's CPAN archive or the Fedora Package Database, but for Kubernetes packages.

Release is an instance of a chart running in a Kubernetes cluster. One chart can often be installed many times into the same cluster. And each time it is installed, a new release is created.

Helm installs charts into Kubernetes, creating a new release for each installation. And to find new charts, you can search Helm chart repositories.

See: Using Helm for additional details

With Helm charts you can define the hostname, ingress ports, and other details around the operation of a k8 service.

Important Commands

See: Chart management

sh
helm create <name> # Setup directory with default helm chart
helm package <chart-path> # Packages into version chart archive
helm package  helm/charts/${CI_PROJECT_NAME} --app-version ${IMAGE_VERSION} --version ${HELM_VERSION}
helm lint <chart> # Validate the chart and identify possible issues

# Upload chart to helm registry hosted as OCI
curl -u ${HELM_USERNAME}:${HELM_PASSWORD} --data-binary "@${HELM_PACKAGE}" ${HELM_SERVER}/api/charts
helm create <name> # Setup directory with default helm chart
helm package <chart-path> # Packages into version chart archive
helm package  helm/charts/${CI_PROJECT_NAME} --app-version ${IMAGE_VERSION} --version ${HELM_VERSION}
helm lint <chart> # Validate the chart and identify possible issues

# Upload chart to helm registry hosted as OCI
curl -u ${HELM_USERNAME}:${HELM_PASSWORD} --data-binary "@${HELM_PACKAGE}" ${HELM_SERVER}/api/charts