Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## In Development
* BREAKING: Use the standardized labels recommended in the Helm docs. You can use `migrations/v1.0/standardize-labels.sh` to prepare an existing cluster before running `helm update`. (#351) (by @cognifloyd)
* Drop support for `networking.k8s.io/v1beta1` which was removed in kubernetes v1.22 (EOL 2022-10-28) (#353) (by @cognifloyd)

## v0.110.0
Expand All @@ -9,7 +10,7 @@
* Update the GitHub badges. (#345) (by @mamercad)
* Reorganizing and renaming the CI workflows and jobs. (#344) (by @mamercad)
* Add support for providing `ingressClassName`. (#336) (by @mamercad)
* Add an experimental GitHu/K3s Lint and End-to-End testing workflow. (#243) (by @mamercad)
* Add an experimental GitHub/K3s Lint and End-to-End testing workflow. (#243) (by @mamercad)
* Set `st2client` resources by `values.yaml`. (#337) (by @mamercad)
* Switch to the official `bats` Docker image for e2e tests. (#338)
* Temporary workaround for #311 to use previous bitnami index from: https://github.com/bitnami/charts/issues/10539 (#312 #318) (by @0xhaven)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ A helper container to switch into and run st2 CLI commands against the deployed
All resources like credentials, configs, RBAC, packs, keys and secrets are shared with this container.
```
# obtain st2client pod name
ST2CLIENT=$(kubectl get pod -l app=st2client -o jsonpath="{.items[0].metadata.name}")
ST2CLIENT=$(kubectl get pod -l app.kubernetes.io/name=st2client -o jsonpath="{.items[0].metadata.name}")

# run a single st2 client command
kubectl exec -it ${ST2CLIENT} -- st2 --version
Expand Down Expand Up @@ -320,12 +320,12 @@ This mirrors the how pack registration works. Make sure to review any upgrade no
## Tips & Tricks
Grab all logs for entire StackStorm cluster with dependent services in Helm release:
```
kubectl logs -l release=<release-name>
kubectl logs -l app.kubernetes.io/instance=<release-name>
```

Grab all logs only for stackstorm backend services, excluding st2web and DB/MQ/redis:
```
kubectl logs -l release=<release-name>,tier=backend
kubectl logs -l app.kubernetes.io/instance=<release-name>,app.kubernetes.io/component=backend
```

## Running jobs before/after install, upgrade, or rollback
Expand Down
117 changes: 117 additions & 0 deletions migrations/v1.0/standardize-labels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/bin/bash

# We switched to the standard labels recommend in Helm's "Best Practices" doc.
# https://helm.sh/docs/chart_best_practices/labels/#standard-labels
#
# This script adds those labels to all the resources in an existing release,
# so that helm upgrade will not create duplicate resources. The new label
# selectors do not match the old labels, so this script adds the new labels
# to the old resources. Thus, the new selectors will update them.

# These env vars need to be set to use this script:
# RELEASE_NAME (same as .Release.Name)
# NAMESPACE (same as .Release.Namespace)
#
# For example:
# RELEASE_NAME=st2 NAMESPACE=st2 migrations/standardize-labels.sh

RELEASE_NAME=${RELEASE_NAME:-st2}
NAMESPACE=${NAMESPACE:-default}
CHART_NAME=${CHART_NAME:-stackstorm-ha} # see Chart.yaml


function klabel_app_instance() {
kind=${1}
kubectl label "${kind}" \
-n "${NAMESPACE}" \
-l "vendor=stackstorm" \
-l "release=${RELEASE_NAME}" \
"app.kubernetes.io/instance=${RELEASE_NAME}"
}

function klabel_app_name() {
kind=${1}
app=${2}
kubectl label "${kind}" \
-n "${NAMESPACE}" \
-l "vendor=stackstorm" \
-l "release=${RELEASE_NAME}" \
-l "app=${app}" \
"app.kubernetes.io/name=${app}"
}

function k_get_app_names() {
kind=${1}
app=${2}
kubectl get "${kind}" \
-n "${NAMESPACE}" \
-l "vendor=stackstorm" \
-l "release=${RELEASE_NAME}" \
-o json \
| jq -r '.items[] | select(.metadata.name | test("'"${app}"'")).metadata.labels.app'
}

echo "Adding label app.kubernetes.io/instance=${RELEASE_NAME} (which will replace release=${RELEASE_NAME}) ..."

for kind in ConfigMap Secret Ingress Service ServiceAccount Deployment ReplicaSet Pod Job; do
klabel_app_instance ${kind}
done

echo
echo "Adding label app.kubernetes.io/name=<app> (which will replace app=<app>) ..."

klabel_app_name ConfigMap st2
klabel_app_name Secret st2
klabel_app_name Secret st2chatops
klabel_app_name ServiceAccount ${CHART_NAME}
klabel_app_name Ingress ingress

deployment_apps=(
st2actionrunner
st2api
st2auth
st2chatops
st2client
st2garbagecollector
st2notifier
st2rulesengine
st2scheduler
$(k_get_app_names Deployment st2sensorcontainer)
st2stream
st2timersengine
st2web
st2workflowengine
)
for app in "${deployment_apps[@]}"; do
echo "Deployment app=${app} ..."
klabel_app_name Deployment ${app}
klabel_app_name ReplicaSet ${app}
klabel_app_name Pod ${app}
done

service_apps=(
st2api
st2auth
st2chatops
st2stream
st2web
)
for app in "${service_apps[@]}"; do
echo "Service app=${app} ..."
klabel_app_name Service ${app}
done

job_apps=(
st2
st2-apply-rbac-definitions
st2-register-content
$(k_get_app_names Job extra-helm-hook)
)
for app in "${job_apps[@]}"; do
echo "Job app=${app} ..."
klabel_app_name Job ${app}
klabel_app_name Pod ${app}
done

klabel_app_name ConfigMap st2tests
klabel_app_name Pod st2tests
2 changes: 1 addition & 1 deletion templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.data.ST2_AUTH_PA
username: {{ .Values.st2.username }}

4. Use st2 CLI:
export ST2CLIENT=$(kubectl get --namespace {{ .Release.Namespace }} pod -l app=st2client,release={{ .Release.Name }} -o jsonpath="{.items[0].metadata.name}")
export ST2CLIENT=$(kubectl get --namespace {{ .Release.Namespace }} pod -l app.kubernetes.io/name=st2client,app.kubernetes.io/instance={{ .Release.Name }} -o jsonpath="{.items[0].metadata.name}")
kubectl exec -it ${ST2CLIENT} --namespace {{ .Release.Namespace }} -- st2 --version

-----------------------------------------------------
Expand Down
19 changes: 11 additions & 8 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@ Usage: "{{ include "stackstorm-ha.labels" (list $ "st2servicename") }}"
{{- define "stackstorm-ha.labels" -}}
{{- $root := index . 0 }}
{{- $name := index . 1 }}
{{- $valuesKey := regexReplaceAll "-.*" $name "" }}
{{- $appVersion := dig $valuesKey "image" "tag" ($root.Values.image.tag) ($root.Values|merge (dict)) }}
{{ include "stackstorm-ha.selectorLabels" . }}
{{- if list "st2web" "ingress" | has $name }}
tier: frontend
app.kubernetes.io/component: frontend
{{- else if eq $name "st2tests" }}
tier: tests
app.kubernetes.io/component: tests
{{- else }}
tier: backend
app.kubernetes.io/component: backend
{{- end }}
vendor: stackstorm
chart: {{ $root.Chart.Name }}-{{ $root.Chart.Version }}
heritage: {{ $root.Release.Service }}
app.kubernetes.io/part-of: stackstorm
app.kubernetes.io/version: {{ tpl $appVersion $root | quote }}
helm.sh/chart: {{ $root.Chart.Name }}-{{ $root.Chart.Version }}
app.kubernetes.io/managed-by: {{ $root.Release.Service }}
{{- end -}}

{{/*
Expand All @@ -32,8 +35,8 @@ Usage: "{{ include "stackstorm-ha.selectorLabels" (list $ "st2servicename") }}"
{{- define "stackstorm-ha.selectorLabels" -}}
{{- $root := index . 0 }}
{{- $name := index . 1 }}
app: {{ $name }}
release: {{ $root.Release.Name }}
app.kubernetes.io/name: {{ $name }}
app.kubernetes.io/instance: {{ $root.Release.Name }}
{{- end -}}

{{/*
Expand Down
8 changes: 1 addition & 7 deletions templates/configmaps_overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ metadata:
name: {{ .Release.Name }}-st2-overrides-configs
annotations:
description: StackStorm override configs defined in helm values, shipped in (or copied to) '/opt/stackstorm/overrides'
labels:
app: st2
tier: backend
vendor: stackstorm
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
labels: {{- include "stackstorm-ha.labels" (list $ "st2") | nindent 4 }}
data:
{{ toYaml .Values.st2.overrides | indent 2 }}
{{- end }}
Loading