Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(http-add-on): Refactor the chart for next version #523

Merged
merged 7 commits into from
Oct 4, 2023
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
163 changes: 95 additions & 68 deletions .github/workflows/ci-http-add-on.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ on:
branches:
- main
paths:
- '.github/workflows/ci-http-add-on.yml'
- 'http-add-on/**'
- ".github/workflows/ci-http-add-on.yml"
- "http-add-on/**"
pull_request:
branches:
- main
paths:
- '.github/workflows/ci-http-add-on.yml'
- 'http-add-on/**'
- ".github/workflows/ci-http-add-on.yml"
- "http-add-on/**"

jobs:
lint-helm-3-x:
name: Lint Helm Chart
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Check out code
uses: actions/checkout@v2

- name: Helm install
uses: Azure/setup-helm@v3
- name: Helm install
uses: Azure/setup-helm@v3

- name: Lint 'http-add-on' Helm chart
run: helm lint http-add-on
- name: Lint 'http-add-on' Helm chart
run: helm lint http-add-on

deploy-helm-3-x:
name: Deploy to Kubernetes ${{ matrix.kubernetesVersion }}
Expand All @@ -38,62 +38,89 @@ jobs:
matrix:
kubernetesVersion: [v1.28, v1.27, v1.26, v1.25]
include:
- kubernetesVersion: v1.28
kindImage: kindest/node:v1.28.0@sha256:b7a4cad12c197af3ba43202d3efe03246b3f0793f162afb40a33c923952d5b31
- kubernetesVersion: v1.27
kindImage: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
- kubernetesVersion: v1.26
kindImage: kindest/node:v1.26.6@sha256:6e2d8b28a5b601defe327b98bd1c2d1930b49e5d8c512e1895099e4504007adb
- kubernetesVersion: v1.25
kindImage: kindest/node:v1.25.11@sha256:227fa11ce74ea76a0474eeefb84cb75d8dad1b08638371ecf0e86259b35be0c8
- kubernetesVersion: v1.28
kindImage: kindest/node:v1.28.0@sha256:b7a4cad12c197af3ba43202d3efe03246b3f0793f162afb40a33c923952d5b31
- kubernetesVersion: v1.27
kindImage: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
- kubernetesVersion: v1.26
kindImage: kindest/node:v1.26.6@sha256:6e2d8b28a5b601defe327b98bd1c2d1930b49e5d8c512e1895099e4504007adb
- kubernetesVersion: v1.25
kindImage: kindest/node:v1.25.11@sha256:227fa11ce74ea76a0474eeefb84cb75d8dad1b08638371ecf0e86259b35be0c8
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Helm install
uses: Azure/setup-helm@v3

- name: Create k8s ${{ matrix.kubernetesVersion }} Kind Cluster
uses: helm/kind-action@main
with:
node_image: ${{ matrix.kindImage }}

- name: Show Kubernetes version
run: |
kubectl version

- name: Show Kubernetes nodes
run: |
kubectl get nodes -o wide

- name: Show Helm version
run: |
helm version

- name: Create KEDA namespace
run: kubectl create ns keda

- name: Install KEDA chart
run: helm install keda ./keda/ --namespace keda

- name: Template Helm chart
run: helm template http-add-on ./http-add-on/ --namespace keda

- name: Install Helm chart
run: helm install http-add-on ./http-add-on/ --namespace keda

- name: Show Kubernetes resources
run: kubectl get all --namespace keda
if: always()

- name: Get all HTTPScaledObjects
run: kubectl get httpscaledobjects

- name: Get all CRDs
run: kubectl get crds

- name: Get HTTPScaledObject CRD
run: kubectl get crds/httpscaledobjects.http.keda.sh

- name: Describe HTTPScaledObject CRD
run: kubectl describe crds/httpscaledobjects.http.keda.sh
- name: Check out code
uses: actions/checkout@v2

- name: Helm install
uses: Azure/setup-helm@v3

- name: Create k8s ${{ matrix.kubernetesVersion }} Kind Cluster
uses: helm/kind-action@main
with:
node_image: ${{ matrix.kindImage }}

- name: Show Kubernetes version
run: |
kubectl version

- name: Show Kubernetes nodes
run: |
kubectl get nodes -o wide

- name: Show Helm version
run: |
helm version

- name: Create KEDA namespace
run: kubectl create ns keda

- name: Install KEDA chart
run: helm install keda ./keda/ --namespace keda

- name: Generate values
run: |
cat <<EOF > test-values.yaml
additionalLabels:
random: value
images:
tag: canary
rbac:
aggregateToDefaultRoles: true
interceptor:
replicas:
min: 1
EOF

- name: Template Helm chart
run: helm template http-add-on ./http-add-on/ --namespace keda --values test-values.yaml

- name: Install Helm chart
run: helm install http-add-on ./http-add-on/ --namespace keda --values test-values.yaml --wait

- name: Show Kubernetes resources
run: kubectl get all --namespace keda
if: always()

- name: Get all HTTPScaledObjects
run: kubectl get httpscaledobjects

- name: Get all CRDs
run: kubectl get crds

- name: Get HTTPScaledObject CRD
run: kubectl get crds/httpscaledobjects.http.keda.sh

- name: Describe HTTPScaledObject CRD
run: kubectl describe crds/httpscaledobjects.http.keda.sh

- name: Validate Interceptor ScaledObject
run: |
for N in {1..3}
do
READY=$(kubectl get so/keda-add-ons-http-interceptor -n keda -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}')
echo "ScaledObjet is ready: $READY"
if [[ "$READY" == "True" ]]; then
exit 0
fi
sleep 15s
done
exit 1
4 changes: 1 addition & 3 deletions http-add-on/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ their default values.

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `additionalLabels` | string | `""` | Additional labels to be applied to installed resources. Note that not all resources will receive these labels. |
| `additionalLabels` | object | `{}` | Additional labels to be applied to installed resources. Note that not all resources will receive these labels. |
| `crds.install` | bool | `true` | Whether to install the `HTTPScaledObject` [`CustomResourceDefinition`](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/) |
| `images.interceptor` | string | `"ghcr.io/kedacore/http-add-on-interceptor"` | Image name for the interceptor image component |
| `images.kubeRbacProxy.name` | string | `"gcr.io/kubebuilder/kube-rbac-proxy"` | Image name for the Kube RBAC Proxy image component |
Expand All @@ -98,8 +98,6 @@ their default values.

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `operator.adminPort` | int | `9090` | The port for the operator's admin server to run on |
| `operator.adminService` | string | `"operator-admin"` | The name of the [`Service`](https://kubernetes.io/docs/concepts/services-networking/service/) for the operator's admin server |
| `operator.affinity` | object | `{}` | Affinity for pod scheduling ([docs](https://kubernetes.io/docs/tasks/configure-pod-container/assign-pods-nodes-using-node-affinity/)) |
| `operator.imagePullSecrets` | list | `[]` | The image pull secrets for the operator component |
| `operator.nodeSelector` | object | `{}` | Node selector for pod scheduling ([docs](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/)) |
Expand Down
7 changes: 3 additions & 4 deletions http-add-on/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "keda-addons-http.chart" -}}
{{- define "keda-http-add-on.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Generate basic labels
*/}}
{{- define "keda-addons-http.labels" }}
helm.sh/chart: {{ include "keda-addons-http.chart" . }}
app.kubernetes.io/component: controller-manager
{{- define "keda-http-add-on.labels" }}
helm.sh/chart: {{ include "keda-http-add-on.chart" . }}
app.kubernetes.io/part-of: {{ .Chart.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,21 @@ apiVersion: apps/v1
kind: Deployment
metadata:
labels:
control-plane: interceptor
httpscaledobjects.http.keda.sh/version: {{ .Values.images.tag | default .Chart.AppVersion }}
keda.sh/addon: {{ .Chart.Name }}
app: {{ .Chart.Name }}
name: {{ .Chart.Name }}-interceptor
app.kubernetes.io/name: {{ .Chart.Name }}-interceptor
app.kubernetes.io/version: {{ .Values.images.tag | default .Chart.AppVersion }}
app.kubernetes.io/component: interceptor
app.kubernetes.io/part-of: {{ .Chart.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{ tpl .Values.additionalLabels . | indent 4}}
{{- include "keda-http-add-on.labels" . | indent 4 }}
name: {{ .Chart.Name }}-interceptor
namespace: {{ .Release.Namespace }}
spec:
replicas: {{ .Values.interceptor.replicas.min }}
selector:
matchLabels:
control-plane: interceptor
httpscaledobjects.http.keda.sh/version: {{ .Values.images.tag | default .Chart.AppVersion }}
keda.sh/addon: {{ .Chart.Name }}
app.kubernetes.io/component: interceptor
{{- include "keda-http-add-on.labels" . | indent 6 }}
template:
metadata:
labels:
control-plane: interceptor
httpscaledobjects.http.keda.sh/version: {{ .Values.images.tag | default .Chart.AppVersion }}
keda.sh/addon: {{ .Chart.Name }}
app: {{ .Chart.Name }}
name: {{ .Chart.Name }}-interceptor
app.kubernetes.io/name: {{ .Chart.Name }}-interceptor
app.kubernetes.io/version: {{ .Values.images.tag | default .Chart.AppVersion }}
app.kubernetes.io/component: interceptor
app.kubernetes.io/part-of: {{ .Chart.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{ tpl .Values.additionalLabels . | indent 4}}
{{- include "keda-http-add-on.labels" . | indent 8 }}
spec:
imagePullSecrets:
{{- toYaml .Values.interceptor.imagePullSecrets | nindent 8 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
httpscaledobjects.http.keda.sh/version: {{ .Values.images.tag | default .Chart.AppVersion }}
keda.sh/addon: {{ .Chart.Name }}
app: {{ .Chart.Name }}
name: {{ .Chart.Name }}-interceptor
app.kubernetes.io/name: {{ .Chart.Name }}-interceptor
{{- include "keda-addons-http.labels" . | indent 4 }}
{{- include "keda-http-add-on.labels" . | indent 4 }}
name: {{ .Chart.Name }}-interceptor
rules:
- apiGroups:
Expand Down Expand Up @@ -36,7 +31,7 @@ metadata:
app: {{ .Chart.Name }}
name: {{ .Chart.Name }}-interceptor
app.kubernetes.io/name: {{ .Chart.Name }}-interceptor
{{- include "keda-addons-http.labels" . | indent 4 }}
{{- include "keda-http-add-on.labels" . | indent 4 }}
name: {{ .Chart.Name }}-interceptor
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: ScaledObject
metadata:
name: "{{ .Chart.Name }}-interceptor"
namespace: {{ .Release.Namespace }}
labels:
{{- include "keda-http-add-on.labels" . | indent 4 }}
spec:
minReplicaCount: {{ .Values.interceptor.replicas.min }}
maxReplicaCount: {{ .Values.interceptor.replicas.max }}
Expand All @@ -14,5 +16,5 @@ spec:
triggers:
- type: external
metadata:
scalerAddress: "{{ .Chart.Name }}-{{ .Values.scaler.service }}:{{ default 9091 .Values.scaler.grpcPort }}"
scalerAddress: "{{ .Chart.Name }}-{{ .Values.scaler.service }}.{{ .Release.Namespace }}:{{ default 9091 .Values.scaler.grpcPort }}"
interceptorTargetPendingRequests: "{{ default 200 .Values.scaler.pendingRequestsInterceptor }}"
15 changes: 15 additions & 0 deletions http-add-on/templates/interceptor/service-admin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/component: interceptor-admin
{{- include "keda-http-add-on.labels" . | indent 4 }}
name: "{{ .Chart.Name }}-{{ .Values.interceptor.admin.service }}"
namespace: {{ .Release.Namespace }}
spec:
ports:
- name: https
port: {{ default 9091 .Values.interceptor.admin.port }}
targetPort: inter-admin
selector:
app.kubernetes.io/component: interceptor
15 changes: 15 additions & 0 deletions http-add-on/templates/interceptor/service-proxy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/component: interceptor-proxy
{{- include "keda-http-add-on.labels" . | indent 4 }}
name: "{{ .Chart.Name }}-{{ .Values.interceptor.proxy.service }}"
namespace: {{ .Release.Namespace }}
spec:
ports:
- name: http
port: {{ default 9091 .Values.interceptor.proxy.port }}
targetPort: inter-proxy
selector:
app.kubernetes.io/component: interceptor
8 changes: 8 additions & 0 deletions http-add-on/templates/interceptor/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/component: interceptor
{{- include "keda-http-add-on.labels" . | indent 4 }}
name: {{ .Chart.Name }}-interceptor
namespace: {{ .Release.Namespace }}
Loading
Loading