Skip to content

Package Managers

What is a package manager?πŸ’£

HelmπŸ’£

  • Helm is a configuration management tool for Kubernetes.
  • It uses a set of templates to allow customization of application configuration.
  • Helm is a CNCF project with a large community built around it.
  • Key Concepts:
    • A Helm Chart is a bundle of information necessary to create an instance of a Kubernetes application.
    • The chart holds configuration data for merging into a packaged chart to create a release object.
    • A release is a running instance of a chart, combined with a specific config.

Helm ChartsπŸ’£

  • Application Packages are called Helm Charts.
  • A chart is a way to define an application.
  • File Structure:
    • Chart.yaml: Information about the chart, such as author, version, description, and image location.
    • values.yaml: Default configuration values for the chart.
    • templates: A directory of templates that, when combined with values, will generate valid Kubernetes manifest files.
  • Helm CLI is available from GitHub or Homebrew.

Helm Chart StructureπŸ’£

MyChart/
|── Chart.yaml                     #Required
|── LICENSE
|── values.yaml                    #Required
|── values.schema.json 
|── charts/                        #Required
    └── dependent charts 
|── crds/ 
    └── needed crds 
└── templates/                     #Required
    |── deployment.yaml 
    |── ingress.yaml
    |── service.yaml
    |── NOTES.txt
    └── tests/
        └── test-connection.yaml

Example Helm Chart FilesπŸ’£

Example values.yaml

# The istio profile to use
profile: default

# The hub to use for the image, note: the image is built as:
hub: registryl.dsop.io/ironbank/opensource/istio

# The tag to use for the image
tag: 1.7.3
# The hostname to use for the default gateway
hostname: bigbang.dev

imagePullSecrets:
  []
# - private-registry

tls:
  credentialName: wildcard-cert 
  mode: SIMPLE

Example template file

apiVersion: install.istio.io/vlalpha1
kind: IstioOperator
metadata:
  name: istiocontrolplane
  namespace: {{ .Release. Namespace }}
spec:
  profile: {{ .Values.profile }}
  hub: {{ .Values.hub }}
  tag: {{ .Values.tag }}

  components:
    ingressGateways:
      - name: istio-ingressgateway
      namespace: {{ .Release.Namespace }}
      enabled: true
      k85:
        hpaSpec:
          minReplicas: {{ .Values.ingressGateway.minReplicas }}
          maxReplicas: {{ .Values.ingressGateway.maxReplicas }}
          metrics:
            - type: Resource
              resource:
                name: cpu
                targetAverageUtilization: 60
          scaleTargetRef:
            apiVersion: apps/v1
            kind: Development

How Big Bang uses HelmπŸ’£

  • Helm can manage a chart’s lifecycle.
  • Flux can manage a chart’s lifecycle.
  • All core Big Bang components are installed as Helm Charts.

KustomizeπŸ’£

Kustomize is template-free configuration customization for Kubernetes that allows you to reuse manifests across all of your environments (dev, stage, prod) and then overlay unique specifications for each.

  • Kustomize has a CLI for managing kubernetes style objects in a declarative way.
  • It is built into kubectl natively.
  • Customizations for any file can be defined declaratively, as needed.
    • This is done through overlay files that customize the base yaml configurations.
    • Kustomize build.

Kustomize File StructureπŸ’£

hello-world/ 
|── base
| β”œβ”€β”€ deployment.yaml
| └── kustomization.yaml
└── overlays
    |── production
    | β”œβ”€β”€ replica_count.yaml
    | └── kustomization.yaml 
    └── staging
      β”œβ”€β”€ replica_count.yaml 
      └── kustomization.yaml

Kustomize File RenderingπŸ’£

Assuming the structure above, let’s see how Kustomize combines base files and overlays to arrive at a materialized file. Assume the files below:

hello-world/base/deployment.yaml

apiVersion: apps/v1 
kind: Deployment 
metadata:
  name: hello-world
spec:
  replicas: 1
  selector:
     matchLabels:
       app: hello-world
  template:
    metadata:
      labels:
        app: hello-world
    spec:
      containers:
      - name: hello-world 
      image: nginx 
      resources:
        limits:
          memory: "128Mi"
          cpu: "500m"
      ports:
      - containerPort: 80

hello-world/base/kustomization.yaml

resources:
  - deployment.yaml

hello-world/overlays/staging/replica_cound.yaml

apiVersion: apps/v1
kind: Deployment
metatdata:
  name: hello-world
spec:
  replicas: 3

hello-world/base/kustomization.yaml

bases:
  - dep../../base
patches:
  - replica_count.yaml

The resultant output of running the following command, notice that the replicas spec has been updated to 3.

kustomize build hello-world/overlays/staging/

Will be the below:

apiVersion: apps/v1 
kind: Deployment 
metadata:
  name: hello-world
spec:
  replicas: 3
  selector:
     matchLabels:
       app: hello-world
  template:
    metadata:
      labels:
        app: hello-world
    spec:
      containers:
      - name: hello-world 
      image: nginx 
      resources:
        limits:
          memory: "128Mi"
          cpu: "500m"
      ports:
      - containerPort: 80

Additional Kustomize FeaturesπŸ’£

  • Name prefix
    • Add a prefix to all resource names.
  • Common Labels
    • Adds labels to all resources.
  • Common Annotations
    • Adds annotations to all resources.
  • ConfigMap Generator
    • Take a file and turns the contents into a configmap.
  • SOPS Secret Generator
    • (Big Bang Enabled alpha plugin) Takes a file and turns the contents into a Secret.

Quiz QuestionsπŸ’£

What is a Package Manager?

A Package Manager is a tool or collection of tools that automates the process of installing, upgrading, configuring, and removing computer programs for a computer in a consistent manner.

The Package Managing tool the Big Bang uses is Helm

What are the required components of the Helm Chart structure?

The required files are: Chart.yaml and values.yaml

The required folders are: charts/ and templates/

How does Big Bang use Helm?

Big Bang uses helm to manage a chart’s lifecycle, install all core Big Bang components as Helm Charts, and uses Flux can manage a chart’s lifecycle