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