Skip to content

Commit 3f85d9e

Browse files
Merge pull request #7 from restackio/operator
Add Operator
2 parents e201ae4 + 951507e commit 3f85d9e

File tree

4 files changed

+157
-0
lines changed

4 files changed

+157
-0
lines changed

restack/templates/ingress.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,17 @@ spec:
6464
serviceName: {{ $fullName }}-stream
6565
servicePort: 9233
6666
{{- end }}
67+
- path: /operator
68+
pathType: Prefix
69+
backend:
70+
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
71+
service:
72+
name: {{ $fullName }}-operator
73+
port:
74+
number: 10233
75+
{{- else }}
76+
serviceName: {{ $fullName }}-operator
77+
servicePort: 10233
78+
{{- end }}
6779
{{- end }}
6880
{{- end }}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "restack.fullname" . }}-operator
5+
labels:
6+
{{- include "restack.operatorLabels" . | nindent 4 }}
7+
annotations:
8+
reloader.stakater.com/search: "true"
9+
spec:
10+
strategy:
11+
type: RollingUpdate
12+
rollingUpdate:
13+
maxSurge: 1
14+
maxUnavailable: 1
15+
selector:
16+
matchLabels:
17+
{{- include "restack.operatorSelectorLabels" . | nindent 6 }}
18+
template:
19+
metadata:
20+
labels:
21+
{{- include "restack.operatorSelectorLabels" . | nindent 8 }}
22+
spec:
23+
{{- with .Values.imagePullSecrets }}
24+
imagePullSecrets:
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
serviceAccountName: {{ include "restack.serviceAccountName" . }}
28+
securityContext:
29+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
30+
{{- if .Values.logs.gcp.bucket }}
31+
initContainers:
32+
- name: workload-identity-initcontainer
33+
image: gcr.io/google.com/cloudsdktool/cloud-sdk:alpine
34+
command:
35+
- '/bin/bash'
36+
- '-c'
37+
- |
38+
curl -sS -H 'Metadata-Flavor: Google' 'http://169.254.169.254/computeMetadata/v1/instance/service-accounts/default/token' --retry 30 --retry-connrefused --retry-max-time 60 --connect-timeout 3 --fail --retry-all-errors > /dev/null && exit 0 || echo 'Retry limit exceeded. Failed to wait for metadata server to be available. Check if the gke-metadata-server Pod in the kube-system namespace is healthy.' >&2; exit 1
39+
{{- end }}
40+
containers:
41+
- name: {{ .Chart.Name }}-operator
42+
envFrom:
43+
- configMapRef:
44+
name: {{ include "restack.fullname" . }}-configmap
45+
- secretRef:
46+
name: {{ include "restack.fullname" . }}-secret
47+
securityContext:
48+
{{- toYaml .Values.securityContext | nindent 12 }}
49+
image: ghcr.io/restackio/restack-operator-cloud:main
50+
imagePullPolicy: Always
51+
ports:
52+
- containerPort: 10233
53+
name: operator
54+
resources:
55+
{{- toYaml .Values.operator.resources | nindent 12 }}
56+
57+
{{- if .Values.logs.enabled }}
58+
# Sidecar container for logging
59+
- name: deployment-logs
60+
image: ghcr.io/restackio/k8s-logs-sidecar:main
61+
imagePullPolicy: Always
62+
env:
63+
- name: POD_NAMESPACE
64+
valueFrom:
65+
fieldRef:
66+
fieldPath: metadata.namespace
67+
- name: DEPLOYMENT_NAME
68+
value: {{ include "restack.fullname" . }}-operator
69+
- name: GCS_BUCKET_NAME
70+
value: {{ .Values.logs.gcp.bucket }}
71+
- name: POD_SELECTOR
72+
value: {{ include "restack.name" . }}-operator
73+
- name: CONTAINER_LOGS_NAME
74+
value: {{ .Chart.Name }}-operator
75+
{{- end }}
76+
77+
{{- with .Values.nodeSelector }}
78+
nodeSelector:
79+
{{- toYaml . | nindent 8 }}
80+
{{- end }}
81+
{{- with .Values.affinity }}
82+
affinity:
83+
{{- toYaml . | nindent 8 }}
84+
{{- end }}
85+
{{- with .Values.tolerations }}
86+
tolerations:
87+
{{- toYaml . | nindent 8 }}
88+
{{- end }}

restack/templates/operator/hpa.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{- if .Values.operator.hpa.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "restack.fullname" . }}-operator-hpa
6+
spec:
7+
scaleTargetRef:
8+
apiVersion: apps/v1
9+
kind: Deployment
10+
name: {{ include "restack.fullname" . }}-operator
11+
minReplicas: {{ .Values.operator.hpa.minReplicas }}
12+
maxReplicas: {{ .Values.operator.hpa.maxReplicas }}
13+
metrics:
14+
- type: Resource
15+
resource:
16+
name: cpu
17+
target:
18+
type: Utilization
19+
averageUtilization: {{ .Values.operator.hpa.averageUtilization.cpu }}
20+
- type: Resource
21+
resource:
22+
name: memory
23+
target:
24+
type: Utilization
25+
averageUtilization: {{ .Values.operator.hpa.averageUtilization.memory }}
26+
behavior:
27+
scaleUp:
28+
stabilizationWindowSeconds: 0 # increased stabilization window for scale up
29+
selectPolicy: Max
30+
policies:
31+
- type: Pods
32+
value: 1 # reduced value for scale up
33+
periodSeconds: 30
34+
scaleDown:
35+
stabilizationWindowSeconds: 300 # increased stabilization window for scale down
36+
selectPolicy: Max
37+
policies:
38+
- type: Pods
39+
value: 1 # reduced value for scale down
40+
periodSeconds: 60
41+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "restack.fullname" . }}-operator
5+
labels:
6+
{{- include "restack.operatorLabels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
ports:
10+
- port: 10233
11+
targetPort: 10233
12+
protocol: TCP
13+
name: operator
14+
15+
selector:
16+
{{- include "restack.operatorSelectorLabels" . | nindent 4 }}

0 commit comments

Comments
 (0)