DodoApp: Expose same app ports on VM as well
Change-Id: I5d04330ffc7c23443c1305ece5201e3f59fb91d4
diff --git a/charts/virtual-machine/templates/service.yaml b/charts/virtual-machine/templates/service.yaml
index b79b385..9af7476 100644
--- a/charts/virtual-machine/templates/service.yaml
+++ b/charts/virtual-machine/templates/service.yaml
@@ -7,4 +7,9 @@
selector:
app: {{ .Values.name }}
ports:
- {{- toYaml .Values.servicePorts | nindent 4 }}
+ {{- range .Values.ports }}
+ - name: {{ .name }}
+ port: {{ .value }}
+ targetPort: {{ .name }}
+ protocol: {{ .protocol }}
+ {{- end }}
diff --git a/charts/virtual-machine/templates/vm.yaml b/charts/virtual-machine/templates/vm.yaml
index 40c4a34..3a0a446 100644
--- a/charts/virtual-machine/templates/vm.yaml
+++ b/charts/virtual-machine/templates/vm.yaml
@@ -25,9 +25,11 @@
# masquerade: {}
bridge: {}
ports:
- {{- range .Values.ports }}
- - port: {{ . }}
- {{- end }}
+ {{- range .Values.ports }}
+ - name: {{ .name }}
+ port: {{ .value }}
+ protocol: {{ .protocol }}
+ {{- end }}
disks:
- name: disk0
disk:
diff --git a/charts/virtual-machine/values.yaml b/charts/virtual-machine/values.yaml
index 79ea0a9..0199d6f 100644
--- a/charts/virtual-machine/values.yaml
+++ b/charts/virtual-machine/values.yaml
@@ -8,4 +8,3 @@
cloudInit:
userData: "" # base64 encoded
networkData: "" # base64 encoded
-ports: []
diff --git a/core/installer/app_configs/app_base.cue b/core/installer/app_configs/app_base.cue
index 122faa7..5b4b974 100644
--- a/core/installer/app_configs/app_base.cue
+++ b/core/installer/app_configs/app_base.cue
@@ -32,6 +32,14 @@
namespaces: [...#Namespace] | *[]
+#Protocol: "TCP" | "UDP"
+
+#Port: {
+ name: string
+ value: int & > 0 & < 65536
+ protocol: #Protocol | *"TCP"
+}
+
#AppType: "infra" | "env"
appType: #AppType | *"env"
@@ -156,6 +164,8 @@
sshKnownHosts: [...string] | *[]
sshAuthorizedKeys: [...string] | *[]
cloudInit: #CloudInit
+ ports: [...#Port]
+ _ports: ports
_name: name
_cpuCores: cpuCores
@@ -219,23 +229,23 @@
source: "https://cloud.debian.org/images/cloud/bookworm-backports/latest/debian-12-backports-generic-amd64.qcow2"
size: "64Gi"
}
- ports: [22, 8080, _codeServerPort]
- servicePorts: [{
+ ports: [{
name: "ssh"
- port: 22
- targetPort: 22
+ value: 22
protocol: "TCP"
}, {
- name: "web"
- port: 80
- targetPort: 8080
- protocol: "TCP"
- }, {
- name: _codeServerPortName
- port: _codeServerPort
- targetPort: _codeServerPort
- protocol: "TCP"
- }]
+ if codeServerEnabled {
+ name: _codeServerPortName
+ value: _codeServerPort
+ protocol: "TCP"
+ }
+ },
+ for p in _ports {
+ name: p.name
+ value: p.value
+ protocol: p.protocol
+ }
+ ]
cloudInit: {
userData: base64.Encode(null, "#cloud-config\n\(yaml.Marshal(_cloudInitUserData))")
networkData: base64.Encode(null, yaml.Marshal({
diff --git a/core/installer/app_configs/dodo_app.cue b/core/installer/app_configs/dodo_app.cue
index 930c74d..87a1f5f 100644
--- a/core/installer/app_configs/dodo_app.cue
+++ b/core/installer/app_configs/dodo_app.cue
@@ -34,6 +34,7 @@
codeServerEnabled: true
cpuCores: 2
memory: "3Gi"
+ ports: app.ports
cloudInit: {
_loadEnvFile: "/home/\(username)/.dodo_env.sh"
writeFiles: [{
@@ -89,14 +90,6 @@
env: [...string] | *[]
}
-#Protocol: "TCP" | "UDP"
-
-#Port: {
- name: string
- value: int & > 0 & < 65536
- protocol: #Protocol | *"TCP"
-}
-
#AppTmpl: {
type: string
cluster?: string