diff --git a/changelog/v0.34.1/container-ports.yaml b/changelog/v0.34.1/container-ports.yaml new file mode 100644 index 000000000..2177d7418 --- /dev/null +++ b/changelog/v0.34.1/container-ports.yaml @@ -0,0 +1,5 @@ +changelog: + - type: NEW_FEATURE + issueLink: https://github.com/solo-io/skv2/issues/495 + description: > + Allow users to configure container ports for the `container` and `sidecar`. diff --git a/codegen/cmd_test.go b/codegen/cmd_test.go index 99154e691..5c6fbc140 100644 --- a/codegen/cmd_test.go +++ b/codegen/cmd_test.go @@ -110,6 +110,10 @@ var _ = Describe("Cmd", func() { Repository: "gloo-mesh-mgmt-server", Tag: "0.0.1", }, + ContainerPorts: []ContainerPort{{ + Name: "stats", + Port: "{{ $Values.glooMgmtServer.statsPort }}", + }}, VolumeMounts: []v1.VolumeMount{{ Name: "license-keys", MountPath: "/etc/gloo-mesh/license-keys", @@ -149,6 +153,7 @@ var _ = Describe("Cmd", func() { Expect(deployment).To(ContainSubstring(fmt.Sprintf("{{ if %s }}", "and ($.Values.glooAgent.enabled) (not $.Values.glooAgent.runAsSidecar)"))) Expect(deployment).To(ContainSubstring("name: agent-volume")) Expect(deployment).To(ContainSubstring("{{ $glooAgent.ports.grpc }}")) + Expect(deployment).To(ContainSubstring("{{ $Values.glooMgmtServer.statsPort }}")) }) It("generates controller code and manifests for a proto file", func() { cmd := &Command{ diff --git a/codegen/model/chart.go b/codegen/model/chart.go index 2576ff670..4a482d889 100644 --- a/codegen/model/chart.go +++ b/codegen/model/chart.go @@ -131,6 +131,12 @@ type Container struct { Env []corev1.EnvVar Resources *corev1.ResourceRequirements SecurityContext *corev1.SecurityContext + ContainerPorts []ContainerPort +} + +type ContainerPort struct { + Name string + Port string } type ReadinessProbe struct { diff --git a/codegen/templates/chart/operator-deployment.yamltmpl b/codegen/templates/chart/operator-deployment.yamltmpl index 5d55289a9..ce3f76d30 100644 --- a/codegen/templates/chart/operator-deployment.yamltmpl +++ b/codegen/templates/chart/operator-deployment.yamltmpl @@ -102,6 +102,13 @@ spec: args: [[ toYaml $container.Args | indent 8 ]] [[- end ]] +[[- if $container.ContainerPorts ]] + ports: + [[- range $port := $container.ContainerPorts ]] + - name: [[ $port.Name ]] + containerPort: [[ $port.Port ]] + [[- end ]] +[[- end ]] {{- if [[ $containerVar ]].env }} env: {{ toYaml [[ $containerVar ]].env | indent 10 }} diff --git a/codegen/test/chart/conditional-sidecar/templates/deployment.yaml b/codegen/test/chart/conditional-sidecar/templates/deployment.yaml index 46cc18d11..fdbc628e4 100644 --- a/codegen/test/chart/conditional-sidecar/templates/deployment.yaml +++ b/codegen/test/chart/conditional-sidecar/templates/deployment.yaml @@ -48,6 +48,9 @@ spec: - name: gloo-mgmt-server image: {{ $glooMgmtServerImage.registry }}/{{ $glooMgmtServerImage.repository }}:{{ $glooMgmtServerImage.tag }} imagePullPolicy: {{ $glooMgmtServerImage.pullPolicy }} + ports: + - name: stats + containerPort: {{ $Values.glooMgmtServer.statsPort }} {{- if $glooMgmtServer.env }} env: {{ toYaml $glooMgmtServer.env | indent 10 }}