k8s-helm
Kubernetes and Helm patterns - use for deployment configs, service definitions, ConfigMaps, Secrets, and Helm chart management
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
Kubernetes & Helm Patterns
Helm Chart Structure
helm/chatkeep/
├── Chart.yaml
├── values.yaml
├── values-dev.yaml
├── values-prod.yaml
├── templates/
│ ├── _helpers.tpl
│ ├── deployment.yaml
│ ├── service.yaml
│ ├── ingress.yaml
│ ├── configmap.yaml
│ ├── secret.yaml
│ ├── hpa.yaml
│ └── serviceaccount.yaml
└── charts/ # Dependencies
Chart.yaml
apiVersion: v2
name: chatkeep
description: Chatkeep Telegram Bot Service
type: application
version: 1.0.0
appVersion: "1.0.0"
dependencies:
- name: postgresql
version: "12.x.x"
repository: "https://charts.bitnami.com/bitnami"
condition: postgresql.enabled
values.yaml
# Image configuration
image:
repository: registry.example.com/chatkeep
tag: latest
pullPolicy: IfNotPresent
# Replica configuration
replicaCount: 2
# Resource limits
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 500m
memory: 512Mi
# Service configuration
service:
type: ClusterIP
port: 80
targetPort: 8080
# Ingress
ingress:
enabled: true
className: nginx
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
hosts:
- host: chatkeep.example.com
paths:
- path: /
pathType: Prefix
tls:
- secretName: chatkeep-tls
hosts:
- chatkeep.example.com
# Environment variables
env:
SPRING_PROFILES_ACTIVE: k8s
SERVER_PORT: "8080"
# Secrets (reference external secrets)
secrets:
BOT_TOKEN:
secretName: chatkeep-bot
key: token
DATABASE_URL:
secretName: chatkeep-db-credentials
key: url
# Health checks
health:
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
initialDelaySeconds: 10
periodSeconds: 5
# Autoscaling
autoscaling:
enabled: true
minReplicas: 2
maxReplicas: 10
targetCPUUtilizationPercentage: 70
# PostgreSQL subchart
postgresql:
enabled: false # Use external database
Deployment Template
# templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "chatkeep.fullname" . }}
labels:
{{- include "chatkeep.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "chatkeep.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
labels:
{{- include "chatkeep.selectorLabels" . | nindent 8 }}
spec:
serviceAccountName: {{ include "chatkeep.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.targetPort }}
protocol: TCP
env:
{{- range $key, $value := .Values.env }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- range $key, $secret := .Values.secrets }}
- name: {{ $key }}
valueFrom:
secretKeyRef:
name: {{ $secret.secretName }}
key: {{ $secret.key }}
{{- end }}
{{- with .Values.health.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.health.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
Service Template
# templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: {{ include "chatkeep.fullname" . }}
labels:
{{- include "chatkeep.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "chatkeep.selectorLabels" . | nindent 4 }}
ConfigMap Template
# templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "chatkeep.fullname" . }}-config
labels:
{{- include "chatkeep.labels" . | nindent 4 }}
data:
application.yaml: |
spring:
profiles:
active: k8s
server:
port: {{ .Values.service.targetPort }}
management:
endpoints:
web:
exposure:
include: health,info,prometheus
Helper Templates
# templates/_helpers.tpl
{{- define "chatkeep.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- define "chatkeep.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- define "chatkeep.labels" -}}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/name: {{ include "chatkeep.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{- define "chatkeep.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chatkeep.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
HorizontalPodAutoscaler
# templates/hpa.yaml
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "chatkeep.fullname" . }}
labels:
{{- include "chatkeep.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "chatkeep.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
Helm Commands
# Install/Upgrade
helm upgrade --install chatkeep ./helm/chatkeep \
-f ./helm/chatkeep/values-prod.yaml \
--namespace chatkeep \
--create-namespace
# Dry run
helm upgrade --install chatkeep ./helm/chatkeep \
--dry-run --debug
# Template only (see generated YAML)
helm template chatkeep ./helm/chatkeep -f values-prod.yaml
# Lint chart
helm lint ./helm/chatkeep
# Rollback
helm rollback chatkeep 1 --namespace chatkeep
# History
helm history chatkeep --namespace chatkeep
# Uninstall
helm uninstall chatkeep --namespace chatkeep
kubectl Commands
# Get pods
kubectl get pods -n chatkeep -l app.kubernetes.io/name=chatkeep
# Logs
kubectl logs -n chatkeep -l app.kubernetes.io/name=chatkeep --tail=100 -f
# Describe deployment
kubectl describe deployment chatkeep -n chatkeep
# Port forward for local testing
kubectl port-forward -n chatkeep svc/chatkeep 8080:80
# Exec into pod
kubectl exec -it -n chatkeep deployment/chatkeep -- /bin/sh
# Apply manually
kubectl apply -f k8s/configmap.yaml -n chatkeep
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-01-20
- Index updated
- 2026-01-26
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!