Skip to content

Commit 2eeacac

Browse files
authored
feat(chart): migrate k8s services (#1156)
Signed-off-by: Miguel <[email protected]>
1 parent 67eaacf commit 2eeacac

File tree

8 files changed

+522
-167
lines changed

8 files changed

+522
-167
lines changed

deployment/chainloop/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: Chainloop is an open source software supply chain control plane, a
77

88
type: application
99
# Bump the patch (not minor, not major) version on each change in the Chart Source code
10-
version: 1.83.1
10+
version: 1.83.2
1111
# Do not update appVersion, this is handled automatically by the release process
1212
appVersion: v0.95.0
1313

deployment/chainloop/README.md

Lines changed: 121 additions & 80 deletions
Large diffs are not rendered by default.

deployment/chainloop/templates/cas/service_grpc.yaml

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,49 @@ apiVersion: v1
77
kind: Service
88
metadata:
99
name: {{ include "chainloop.cas.fullname" . }}-api
10-
labels:
11-
{{- include "chainloop.cas.labels" . | nindent 4 }}
12-
{{- with .Values.cas.serviceAPI.annotations }}
13-
annotations:
14-
{{- toYaml . | nindent 4 }}
10+
namespace: {{ include "common.names.namespace" . | quote }}
11+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
12+
app.kubernetes.io/component: cas
13+
{{- if or .Values.cas.serviceAPI.annotations .Values.commonAnnotations }}
14+
{{- $annotations := include "common.tplvalues.merge" (dict "values" (list .Values.cas.serviceAPI.annotations .Values.commonAnnotations) "context" .) }}
15+
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }}
1516
{{- end }}
1617
spec:
1718
type: {{ .Values.cas.serviceAPI.type }}
19+
{{- if and .Values.cas.serviceAPI.clusterIP (eq .Values.cas.serviceAPI.type "ClusterIP") }}
20+
clusterIP: {{ .Values.cas.serviceAPI.clusterIP }}
21+
{{- end }}
22+
{{- if .Values.cas.serviceAPI.sessionAffinity }}
23+
sessionAffinity: {{ .Values.cas.serviceAPI.sessionAffinity }}
24+
{{- end }}
25+
{{- if .Values.cas.serviceAPI.sessionAffinityConfig }}
26+
sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.cas.serviceAPI.sessionAffinityConfig "context" $) | nindent 4 }}
27+
{{- end }}
28+
{{- if or (eq .Values.cas.serviceAPI.type "LoadBalancer") (eq .Values.cas.serviceAPI.type "NodePort") }}
29+
externalTrafficPolicy: {{ .Values.cas.serviceAPI.externalTrafficPolicy | quote }}
30+
{{- end }}
31+
{{- if and (eq .Values.cas.serviceAPI.type "LoadBalancer") (not (empty .Values.cas.serviceAPI.loadBalancerSourceRanges)) }}
32+
loadBalancerSourceRanges: {{ .Values.cas.serviceAPI.loadBalancerSourceRanges }}
33+
{{- end }}
34+
{{- if and (eq .Values.cas.serviceAPI.type "LoadBalancer") (not (empty .Values.cas.serviceAPI.loadBalancerIP)) }}
35+
loadBalancerIP: {{ .Values.cas.serviceAPI.loadBalancerIP }}
36+
{{- end }}
1837
ports:
19-
- port: {{ .Values.cas.serviceAPI.port }}
20-
targetPort: {{ .Values.cas.serviceAPI.targetPort }}
38+
- name: grpc
39+
{{- $port := coalesce .Values.cas.serviceAPI.port .Values.cas.serviceAPI.ports.http }}
40+
port: {{ $port }}
41+
{{- if not (eq $port .Values.cas.containerPorts.grpc) }}
42+
targetPort: {{ .Values.cas.containerPorts.grpc }}
43+
{{- end }}
2144
protocol: TCP
22-
name: grpc
23-
nodePort: {{ include "chainloop.node_port" .Values.cas.serviceAPI }}
24-
selector:
25-
{{- include "chainloop.cas.selectorLabels" . | nindent 4 }}
45+
{{- if and (or (eq .Values.cas.serviceAPI.type "NodePort") (eq .Values.cas.serviceAPI.type "LoadBalancer")) (not (empty .Values.cas.serviceAPI.nodePorts.http)) }}
46+
nodePort: {{ .Values.cas.serviceAPI.nodePorts.http }}
47+
{{- else if eq .Values.cas.serviceAPI.type "ClusterIP" }}
48+
nodePort: null
49+
{{- end }}
50+
{{- if .Values.cas.serviceAPI.extraPorts }}
51+
{{- include "common.tplvalues.render" (dict "value" .Values.cas.serviceAPI.extraPorts "context" $) | nindent 4 }}
52+
{{- end }}
53+
{{- $podLabels := include "common.tplvalues.merge" (dict "values" (list .Values.cas.podLabels .Values.commonLabels) "context" .) | fromYaml }}
54+
selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}
55+
app.kubernetes.io/component: cas

deployment/chainloop/templates/cas/service_http.yaml

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,49 @@ apiVersion: v1
77
kind: Service
88
metadata:
99
name: {{ include "chainloop.cas.fullname" . }}
10-
labels:
11-
{{- include "chainloop.cas.labels" . | nindent 4 }}
12-
{{- with .Values.cas.service.annotations }}
13-
annotations:
14-
{{- toYaml . | nindent 4 }}
10+
namespace: {{ include "common.names.namespace" . | quote }}
11+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
12+
app.kubernetes.io/component: cas
13+
{{- if or .Values.cas.service.annotations .Values.commonAnnotations }}
14+
{{- $annotations := include "common.tplvalues.merge" (dict "values" (list .Values.cas.service.annotations .Values.commonAnnotations) "context" .) }}
15+
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }}
1516
{{- end }}
1617
spec:
1718
type: {{ .Values.cas.service.type }}
19+
{{- if and .Values.cas.service.clusterIP (eq .Values.cas.service.type "ClusterIP") }}
20+
clusterIP: {{ .Values.cas.service.clusterIP }}
21+
{{- end }}
22+
{{- if .Values.cas.service.sessionAffinity }}
23+
sessionAffinity: {{ .Values.cas.service.sessionAffinity }}
24+
{{- end }}
25+
{{- if .Values.cas.service.sessionAffinityConfig }}
26+
sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.cas.service.sessionAffinityConfig "context" $) | nindent 4 }}
27+
{{- end }}
28+
{{- if or (eq .Values.cas.service.type "LoadBalancer") (eq .Values.cas.service.type "NodePort") }}
29+
externalTrafficPolicy: {{ .Values.cas.service.externalTrafficPolicy | quote }}
30+
{{- end }}
31+
{{- if and (eq .Values.cas.service.type "LoadBalancer") (not (empty .Values.cas.service.loadBalancerSourceRanges)) }}
32+
loadBalancerSourceRanges: {{ .Values.cas.service.loadBalancerSourceRanges }}
33+
{{- end }}
34+
{{- if and (eq .Values.cas.service.type "LoadBalancer") (not (empty .Values.cas.service.loadBalancerIP)) }}
35+
loadBalancerIP: {{ .Values.cas.service.loadBalancerIP }}
36+
{{- end }}
1837
ports:
19-
- port: {{ .Values.cas.service.port }}
20-
targetPort: {{ .Values.cas.service.targetPort }}
38+
- name: http
39+
{{- $port := coalesce .Values.cas.service.port .Values.cas.service.ports.http }}
40+
port: {{ $port }}
41+
{{- if not (eq $port .Values.cas.containerPorts.http) }}
42+
targetPort: {{ .Values.cas.containerPorts.http }}
43+
{{- end }}
2144
protocol: TCP
22-
name: http
23-
nodePort: {{ include "chainloop.node_port" .Values.cas.service }}
24-
selector: {{- include "chainloop.cas.selectorLabels" . | nindent 4 }}
45+
{{- if and (or (eq .Values.cas.service.type "NodePort") (eq .Values.cas.service.type "LoadBalancer")) (not (empty .Values.cas.service.nodePorts.http)) }}
46+
nodePort: {{ .Values.cas.service.nodePorts.http }}
47+
{{- else if eq .Values.cas.service.type "ClusterIP" }}
48+
nodePort: null
49+
{{- end }}
50+
{{- if .Values.cas.service.extraPorts }}
51+
{{- include "common.tplvalues.render" (dict "value" .Values.cas.service.extraPorts "context" $) | nindent 4 }}
52+
{{- end }}
53+
{{- $podLabels := include "common.tplvalues.merge" (dict "values" (list .Values.cas.podLabels .Values.commonLabels) "context" .) | fromYaml }}
54+
selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}
55+
app.kubernetes.io/component: cas

deployment/chainloop/templates/controlplane/config.configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ data:
3434
{{- end }}
3535
cas_server:
3636
grpc:
37-
addr: {{ printf "%s-api:%.0f" (include "chainloop.cas.fullname" .) .Values.cas.serviceAPI.port }}
37+
addr: {{ printf "%s-api:%.0f" (include "chainloop.cas.fullname" .) (coalesce .Values.cas.serviceAPI.port .Values.cas.serviceAPI.ports.http) }}
3838
insecure: {{ empty .Values.cas.tlsConfig.secret.name }}
3939
download_url: {{ include "chainloop.cas.external_url" . }}/download
4040
plugins_dir: {{ .Values.controlplane.pluginsDir }}

deployment/chainloop/templates/controlplane/service_grpc.yaml

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,49 @@ apiVersion: v1
77
kind: Service
88
metadata:
99
name: {{ include "chainloop.controlplane.fullname" . }}-api
10-
labels:
11-
{{- include "chainloop.controlplane.labels" . | nindent 4 }}
12-
{{- with .Values.controlplane.serviceAPI.annotations }}
13-
annotations:
14-
{{- toYaml . | nindent 4 }}
10+
namespace: {{ include "common.names.namespace" . | quote }}
11+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
12+
app.kubernetes.io/component: controlplane
13+
{{- if or .Values.controlplane.serviceAPI.annotations .Values.commonAnnotations }}
14+
{{- $annotations := include "common.tplvalues.merge" (dict "values" (list .Values.controlplane.serviceAPI.annotations .Values.commonAnnotations) "context" .) }}
15+
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }}
1516
{{- end }}
1617
spec:
1718
type: {{ .Values.controlplane.serviceAPI.type }}
19+
{{- if and .Values.controlplane.serviceAPI.clusterIP (eq .Values.controlplane.serviceAPI.type "ClusterIP") }}
20+
clusterIP: {{ .Values.controlplane.serviceAPI.clusterIP }}
21+
{{- end }}
22+
{{- if .Values.controlplane.serviceAPI.sessionAffinity }}
23+
sessionAffinity: {{ .Values.controlplane.serviceAPI.sessionAffinity }}
24+
{{- end }}
25+
{{- if .Values.controlplane.serviceAPI.sessionAffinityConfig }}
26+
sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.controlplane.serviceAPI.sessionAffinityConfig "context" $) | nindent 4 }}
27+
{{- end }}
28+
{{- if or (eq .Values.controlplane.serviceAPI.type "LoadBalancer") (eq .Values.controlplane.serviceAPI.type "NodePort") }}
29+
externalTrafficPolicy: {{ .Values.controlplane.serviceAPI.externalTrafficPolicy | quote }}
30+
{{- end }}
31+
{{- if and (eq .Values.controlplane.serviceAPI.type "LoadBalancer") (not (empty .Values.controlplane.serviceAPI.loadBalancerSourceRanges)) }}
32+
loadBalancerSourceRanges: {{ .Values.controlplane.serviceAPI.loadBalancerSourceRanges }}
33+
{{- end }}
34+
{{- if and (eq .Values.controlplane.serviceAPI.type "LoadBalancer") (not (empty .Values.controlplane.serviceAPI.loadBalancerIP)) }}
35+
loadBalancerIP: {{ .Values.controlplane.serviceAPI.loadBalancerIP }}
36+
{{- end }}
1837
ports:
19-
- port: {{ .Values.controlplane.serviceAPI.port }}
20-
targetPort: {{ .Values.controlplane.serviceAPI.targetPort }}
38+
- name: grpc
39+
{{- $port := coalesce .Values.controlplane.serviceAPI.port .Values.controlplane.serviceAPI.ports.http }}
40+
port: {{ $port }}
41+
{{- if not (eq $port .Values.controlplane.containerPorts.grpc) }}
42+
targetPort: {{ .Values.controlplane.containerPorts.grpc }}
43+
{{- end }}
2144
protocol: TCP
22-
name: grpc
23-
nodePort: {{ include "chainloop.node_port" .Values.controlplane.serviceAPI }}
24-
selector:
25-
{{- include "chainloop.controlplane.selectorLabels" . | nindent 4 }}
45+
{{- if and (or (eq .Values.controlplane.serviceAPI.type "NodePort") (eq .Values.controlplane.serviceAPI.type "LoadBalancer")) (not (empty .Values.controlplane.serviceAPI.nodePorts.http)) }}
46+
nodePort: {{ .Values.controlplane.serviceAPI.nodePorts.http }}
47+
{{- else if eq .Values.controlplane.serviceAPI.type "ClusterIP" }}
48+
nodePort: null
49+
{{- end }}
50+
{{- if .Values.controlplane.serviceAPI.extraPorts }}
51+
{{- include "common.tplvalues.render" (dict "value" .Values.controlplane.serviceAPI.extraPorts "context" $) | nindent 4 }}
52+
{{- end }}
53+
{{- $podLabels := include "common.tplvalues.merge" (dict "values" (list .Values.controlplane.podLabels .Values.commonLabels) "context" .) | fromYaml }}
54+
selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}
55+
app.kubernetes.io/component: controlplane

deployment/chainloop/templates/controlplane/service_http.yaml

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,49 @@ apiVersion: v1
77
kind: Service
88
metadata:
99
name: {{ include "chainloop.controlplane.fullname" . }}
10-
labels:
11-
{{- include "chainloop.controlplane.labels" . | nindent 4 }}
12-
{{- with .Values.controlplane.service.annotations }}
13-
annotations:
14-
{{- toYaml . | nindent 4 }}
10+
namespace: {{ include "common.names.namespace" . | quote }}
11+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
12+
app.kubernetes.io/component: controlplane
13+
{{- if or .Values.controlplane.service.annotations .Values.commonAnnotations }}
14+
{{- $annotations := include "common.tplvalues.merge" (dict "values" (list .Values.controlplane.service.annotations .Values.commonAnnotations) "context" .) }}
15+
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }}
1516
{{- end }}
1617
spec:
1718
type: {{ .Values.controlplane.service.type }}
19+
{{- if and .Values.controlplane.service.clusterIP (eq .Values.controlplane.service.type "ClusterIP") }}
20+
clusterIP: {{ .Values.controlplane.service.clusterIP }}
21+
{{- end }}
22+
{{- if .Values.controlplane.service.sessionAffinity }}
23+
sessionAffinity: {{ .Values.controlplane.service.sessionAffinity }}
24+
{{- end }}
25+
{{- if .Values.controlplane.service.sessionAffinityConfig }}
26+
sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.controlplane.service.sessionAffinityConfig "context" $) | nindent 4 }}
27+
{{- end }}
28+
{{- if or (eq .Values.controlplane.service.type "LoadBalancer") (eq .Values.controlplane.service.type "NodePort") }}
29+
externalTrafficPolicy: {{ .Values.controlplane.service.externalTrafficPolicy | quote }}
30+
{{- end }}
31+
{{- if and (eq .Values.controlplane.service.type "LoadBalancer") (not (empty .Values.controlplane.service.loadBalancerSourceRanges)) }}
32+
loadBalancerSourceRanges: {{ .Values.controlplane.service.loadBalancerSourceRanges }}
33+
{{- end }}
34+
{{- if and (eq .Values.controlplane.service.type "LoadBalancer") (not (empty .Values.controlplane.service.loadBalancerIP)) }}
35+
loadBalancerIP: {{ .Values.controlplane.service.loadBalancerIP }}
36+
{{- end }}
1837
ports:
19-
- port: {{ .Values.controlplane.service.port }}
20-
targetPort: {{ .Values.controlplane.service.targetPort }}
38+
- name: http
39+
{{- $port := coalesce .Values.controlplane.service.port .Values.controlplane.service.ports.http }}
40+
port: {{ $port }}
41+
{{- if not (eq $port .Values.controlplane.containerPorts.http) }}
42+
targetPort: {{ .Values.controlplane.containerPorts.http }}
43+
{{- end }}
2144
protocol: TCP
22-
name: http
23-
nodePort: {{ include "chainloop.node_port" .Values.controlplane.service }}
24-
selector: {{- include "chainloop.controlplane.selectorLabels" . | nindent 4 }}
45+
{{- if and (or (eq .Values.controlplane.service.type "NodePort") (eq .Values.controlplane.service.type "LoadBalancer")) (not (empty .Values.controlplane.service.nodePorts.http)) }}
46+
nodePort: {{ .Values.controlplane.service.nodePorts.http }}
47+
{{- else if eq .Values.controlplane.service.type "ClusterIP" }}
48+
nodePort: null
49+
{{- end }}
50+
{{- if .Values.controlplane.service.extraPorts }}
51+
{{- include "common.tplvalues.render" (dict "value" .Values.controlplane.service.extraPorts "context" $) | nindent 4 }}
52+
{{- end }}
53+
{{- $podLabels := include "common.tplvalues.merge" (dict "values" (list .Values.controlplane.podLabels .Values.commonLabels) "context" .) | fromYaml }}
54+
selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}
55+
app.kubernetes.io/component: controlplane

0 commit comments

Comments
 (0)