Skip to content

Commit ba50d01

Browse files
committed
[vm] Always expose VMs with a service
## What this PR does When VMs are created without a public IP, no service is created for them and they have no in-cluster DNS name. This PR fixes this and resolves #1731. ### Release note ```release-note [vm] Always expose VMs with at least a ClusterIP service. ``` Signed-off-by: Timofei Larkin <[email protected]>
1 parent fe7bdcf commit ba50d01

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎packages/apps/virtual-machine/templates/service.yaml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{{- if .Values.external }}
21
---
32
apiVersion: v1
43
kind: Service
@@ -7,17 +6,24 @@ metadata:
76
labels:
87
apps.cozystack.io/user-service: "true"
98
{{- include "virtual-machine.labels" . | nindent 4 }}
9+
{{- if .Values.external }}
1010
annotations:
1111
networking.cozystack.io/wholeIP: "true"
12+
{{- end }}
1213
spec:
1314
type: {{ ternary "LoadBalancer" "ClusterIP" .Values.external }}
15+
{{- if .Values.external }}
1416
externalTrafficPolicy: Local
1517
{{- if ((include "cozy-lib.network.disableLoadBalancerNodePorts" $) | fromYaml) }}
1618
allocateLoadBalancerNodePorts: false
1719
{{- end }}
20+
{{- else }}
21+
clusterIP: None
22+
{{- end }}
1823
selector:
1924
{{- include "virtual-machine.selectorLabels" . | nindent 4 }}
2025
ports:
26+
{{- if .Values.external }}
2127
{{- if and (eq .Values.externalMethod "WholeIP") (not .Values.externalPorts) }}
2228
- port: 65535
2329
{{- else }}
@@ -27,4 +33,6 @@ spec:
2733
targetPort: {{ . }}
2834
{{- end }}
2935
{{- end }}
36+
{{- else }}
37+
- port: 65535
3038
{{- end }}

‎packages/apps/vm-instance/templates/service.yaml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{{- if .Values.external }}
21
---
32
apiVersion: v1
43
kind: Service
@@ -7,17 +6,24 @@ metadata:
76
labels:
87
apps.cozystack.io/user-service: "true"
98
{{- include "virtual-machine.labels" . | nindent 4 }}
9+
{{- if .Values.external }}
1010
annotations:
1111
networking.cozystack.io/wholeIP: "true"
12+
{{- end }}
1213
spec:
1314
type: {{ ternary "LoadBalancer" "ClusterIP" .Values.external }}
15+
{{- if .Values.external }}
1416
externalTrafficPolicy: Local
1517
{{- if ((include "cozy-lib.network.disableLoadBalancerNodePorts" $) | fromYaml) }}
1618
allocateLoadBalancerNodePorts: false
1719
{{- end }}
20+
{{- else }}
21+
clusterIP: None
22+
{{- end }}
1823
selector:
1924
{{- include "virtual-machine.selectorLabels" . | nindent 4 }}
2025
ports:
26+
{{- if .Values.external }}
2127
{{- if and (eq .Values.externalMethod "WholeIP") (not .Values.externalPorts) }}
2228
- port: 65535
2329
{{- else }}
@@ -27,4 +33,6 @@ spec:
2733
targetPort: {{ . }}
2834
{{- end }}
2935
{{- end }}
36+
{{- else }}
37+
- port: 65535
3038
{{- end }}

0 commit comments

Comments
 (0)