Skip to content

Commit 2b68114

Browse files
authored
Feat/autostopping v2 (#5)
* feat/autostopping-v2 * feat/autostopping-v2 * update discovery values and svc * update discovery values and svc * update notes * 0.2.0-rc1 * readme
1 parent 9b6a130 commit 2b68114

21 files changed

Lines changed: 339 additions & 260 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Makefile
1+
Makefile
2+
*.values.yaml

charts/harness-ccm-autostopping/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.1.4
18+
version: 0.2.0-rc1
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
2323
# It is recommended to use it with quotes.
24-
appVersion: "1.2.1"
24+
appVersion: "2.0.0"

charts/harness-ccm-autostopping/README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,21 @@ helm upgrade -i harness-autostopping --namespace harness-autostopping --create-n
2828
- connectorId: the ID for the CCM K8s connector for this cluster
2929
- apiToken: a Harness API key with at least ccm:admin for all account level resources
3030

31-
## troubleshooting
3231

33-
to turn on debug logging, you can set the following values:
32+
### cluster orchestrator
33+
34+
if you are also using cluster orchestrator, you will need to add annotations for spot nodes:
3435
```yaml
35-
router.logLevel: debug
36+
discovery:
37+
tolerations:
38+
- effect: NoSchedule
39+
key: ccm.harness.io/spot-ready
40+
value: Ready
41+
effect: "NoSchedule"
42+
- key: "compute"
43+
operator: "Equal"
44+
value: "dedicated"
45+
effect: "NoSchedule"
3646
```
3747
3848
## development notes
@@ -41,7 +51,7 @@ things that must be hard-coded:
4151
4252
namespace: `harness-autostopping`
4353

44-
service name for router: `autostopping-router`
54+
deployment name for progress watcher: `progress-agent`
4555

4656
service name for controller: `autostopping-controller` (therefor also hard-coded in the router configmap)
4757

charts/harness-ccm-autostopping/templates/NOTES.txt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ You can now create autostopping rules:
66
name: <autostopping rule name>
77
namespace: <namespace of your k8s application>
88
annotations:
9-
harness.io/cloud-connector-id: <any cloud ccm connector id with autostopping enabled>
9+
harness.io/cloud-connector-id: <any cloud ccm connector id with autostopping enabled>
1010
spec:
11-
service:
12-
name: <replace with your service name>
13-
port: 80
14-
ingress:
15-
name: <replace with ingress name>
16-
controllerName: nginx
17-
idleTimeMins: 15
18-
hideProgressPage: false
11+
idleTimeMins: 5
12+
hideProgressPage: false
13+
workloads:
14+
<autostopping rule name>:
15+
namespace: <namespace of your k8s application>
16+
name: <autostopping rule name>
17+
id: <autostopping rule name>
18+
desired: <desired number of replicas>
19+
type: <k8s resource type>
20+
warmup_delay_sec: 0
21+
traffic_routes:
22+
- service_name: <k8s service name>
23+
service_port: <k8s service port>
24+
dependencies: []

charts/harness-ccm-autostopping/templates/_helpers.tpl

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,17 @@ app.kubernetes.io/component: {{ include "harness-ccm-autostopping.name" . }}-con
5151
{{- end }}
5252

5353
{{/*
54-
Selector labels for router
54+
Selector labels for progress-agent
5555
*/}}
56-
{{- define "harness-ccm-autostopping.router.selectorLabels" -}}
57-
app.kubernetes.io/component: {{ include "harness-ccm-autostopping.name" . }}-router
56+
{{- define "harness-ccm-autostopping.progressAgent.selectorLabels" -}}
57+
app.kubernetes.io/component: {{ include "harness-ccm-autostopping.name" . }}-progress-agent
58+
{{- end }}
59+
60+
{{/*
61+
Selector labels for sd-node
62+
*/}}
63+
{{- define "harness-ccm-autostopping.sdNode.selectorLabels" -}}
64+
app.kubernetes.io/component: {{ include "harness-ccm-autostopping.name" . }}-sd-node
5865
{{- end }}
5966

6067
{{/*
@@ -68,14 +75,28 @@ Create the name of the service account to use
6875
{{- end }}
6976
{{- end }}
7077

78+
{{/*
79+
Create the name of the discovery service account to use
80+
*/}}
81+
{{- define "harness-ccm-autostopping.discoveryServiceAccountName" -}}
82+
{{- if .Values.discovery.serviceAccount.create }}
83+
{{- default (include "harness-ccm-autostopping.fullname" .) .Values.discovery.serviceAccount.name }}
84+
{{- else }}
85+
{{- default "default" .Values.discovery.serviceAccount.name }}
86+
{{- end }}
87+
{{- end }}
88+
7189
{{/*
7290
Define resource names
7391
*/}}
7492
{{- define "harness-ccm-autostopping.controller.name" -}}
7593
{{- include "harness-ccm-autostopping.fullname" . }}-controller
7694
{{- end }}
77-
{{- define "harness-ccm-autostopping.router.name" -}}
78-
{{- include "harness-ccm-autostopping.fullname" . }}-router
95+
{{- define "harness-ccm-autostopping.progressAgent.name" -}}
96+
{{- include "harness-ccm-autostopping.fullname" . }}-progress-agent
97+
{{- end }}
98+
{{- define "harness-ccm-autostopping.sdNode.name" -}}
99+
{{- include "harness-ccm-autostopping.fullname" . }}-sd-node
79100
{{- end }}
80101

81102
{{/*

charts/harness-ccm-autostopping/templates/clusterrole.yaml

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,5 @@
11
apiVersion: rbac.authorization.k8s.io/v1
22
kind: ClusterRole
3-
metadata:
4-
name: {{ include "harness-ccm-autostopping.fullname" . }}-secret-reader
5-
namespace: {{ .Release.Namespace }}
6-
labels:
7-
{{- include "harness-ccm-autostopping.labels" . | nindent 4 }}
8-
rules:
9-
- apiGroups:
10-
- ""
11-
resources:
12-
- secrets
13-
- configmaps
14-
verbs:
15-
- get
16-
- list
17-
- watch
18-
- create
19-
- patch
20-
- delete
21-
- update
22-
23-
---
24-
apiVersion: rbac.authorization.k8s.io/v1
25-
kind: ClusterRole
263
metadata:
274
name: {{ include "harness-ccm-autostopping.fullname" . }}
285
rules:
@@ -93,4 +70,7 @@ rules:
9370
- events
9471
verbs:
9572
- create
96-
- patch
73+
- patch
74+
75+
76+

charts/harness-ccm-autostopping/templates/clusterrolebinding.yaml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
11
apiVersion: rbac.authorization.k8s.io/v1
22
kind: ClusterRoleBinding
3-
metadata:
4-
name: {{ include "harness-ccm-autostopping.fullname" . }}-secret-reader
5-
labels:
6-
{{- include "harness-ccm-autostopping.labels" . | nindent 4 }}
7-
roleRef:
8-
apiGroup: rbac.authorization.k8s.io
9-
kind: ClusterRole
10-
name: {{ include "harness-ccm-autostopping.fullname" . }}-secret-reader
11-
subjects:
12-
- kind: ServiceAccount
13-
name: {{ include "harness-ccm-autostopping.serviceAccountName" . }}
14-
namespace: {{ .Release.Namespace }}
15-
16-
---
17-
apiVersion: rbac.authorization.k8s.io/v1
18-
kind: ClusterRoleBinding
193
metadata:
204
name: {{ include "harness-ccm-autostopping.fullname" . }}
215
roleRef:

charts/harness-ccm-autostopping/templates/controller-deployment.yaml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,26 @@ spec:
3232
- name: {{ include "harness-ccm-autostopping.controller.name" . }}
3333
securityContext:
3434
{{- toYaml .Values.controller.securityContext | nindent 12 }}
35-
image: "{{ .Values.controller.image.repository }}:{{ .Values.controller.image.tag | default .Chart.AppVersion }}"
36-
imagePullPolicy: {{ .Values.controller.image.pullPolicy }}
35+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
36+
imagePullPolicy: {{ .Values.image.pullPolicy }}
37+
command:
38+
- 'operator'
3739
env:
3840
- name: HARNESS_API
3941
value: https://{{ .Values.harnessUrl }}/gateway/lw/api
4042
- name: CONNECTOR_ID
4143
value: {{ .Values.connectorId }}
4244
- name: REMOTE_ACCOUNT_ID
4345
value: {{ .Values.accountId }}
46+
- name: PROGRESS_PAGE_AGENT_SVC
47+
value: {{ include "harness-ccm-autostopping.progressAgent.name" . }}
48+
- name: PROGRESS_PAGE_AGENT_PORT
49+
value: "8290"
50+
- name: PROGRESS_PAGE_AGENT_NS
51+
value: {{ .Release.Namespace }}
52+
- name: ENABLE_TRAFFIC_DETECTION
53+
value: "true"
4454
ports:
45-
- containerPort: 18000
46-
name: envoy-snapshot
47-
- containerPort: 8093
48-
protocol: TCP
49-
name: progress
5055
- containerPort: 9443
5156
protocol: TCP
5257
name: webhook

charts/harness-ccm-autostopping/templates/controller-service.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ metadata:
88
{{- include "harness-ccm-autostopping.labels" . | nindent 4 }}
99
spec:
1010
ports:
11-
- port: 18000
12-
protocol: TCP
13-
name: envoy-snapshot
14-
- port: 80
15-
protocol: TCP
16-
targetPort: 8093
17-
name: progress
1811
- port: 9443
1912
protocol: TCP
2013
targetPort: 9443
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: {{ include "harness-ccm-autostopping.fullname" . }}-discovery
6+
rules:
7+
- apiGroups:
8+
- ""
9+
resources:
10+
- pods
11+
- services
12+
- nodes
13+
verbs:
14+
- watch
15+
- list
16+
- get

0 commit comments

Comments
 (0)