hí ộ
This commit is contained in:
8
templates/charts/generic-http-service/Chart.yaml
Normal file
8
templates/charts/generic-http-service/Chart.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: v2
|
||||
name: generic-http-service
|
||||
description: One HTTP workload — a Deployment and a ClusterIP Service for in-cluster traffic.
|
||||
type: application
|
||||
# Chart version, not the contract version. What a revision pins is templateRef{name, version};
|
||||
# these bytes are one build behind that contract, identified by their content digest.
|
||||
version: 1.0.0
|
||||
appVersion: "1"
|
||||
@@ -0,0 +1,94 @@
|
||||
{{- $s := .Values.spec -}}
|
||||
{{- $p := .Values.platform -}}
|
||||
{{- /* A port below 1024 is privileged: without NET_BIND_SERVICE nothing can bind it, root
|
||||
included, because the container drops every capability. Added exactly when a declared
|
||||
port needs it rather than whenever the pod runs as root. */ -}}
|
||||
{{- $needsBind := false -}}
|
||||
{{- range $s.runtime.ports }}{{- if lt (int .containerPort) 1024 }}{{- $needsBind = true }}{{- end }}{{- end -}}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ $p.name }}
|
||||
namespace: {{ $p.namespace }}
|
||||
labels:
|
||||
{{- toYaml $p.labels | nindent 4 }}
|
||||
annotations:
|
||||
{{- toYaml $p.annotations | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ $s.replicas }}
|
||||
{{- with (default (dict) $p.rollout).progressDeadlineSeconds }}
|
||||
# How long a rollout may make no progress before Kubernetes reports Progressing=False, which is
|
||||
# what the gateway turns into a FAILED phase. Without it a pod that can never start leaves the
|
||||
# console saying "deploying" until the 600s default expires.
|
||||
progressDeadlineSeconds: {{ . }}
|
||||
{{- end }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- toYaml $p.selector | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- toYaml $p.labels | nindent 8 }}
|
||||
annotations:
|
||||
{{- toYaml $p.annotations | nindent 8 }}
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
{{- if $s.runtime.runAsRoot }}
|
||||
# Explicit, never by omission: manifests.py forces runAsNonRoot whenever this is absent.
|
||||
securityContext:
|
||||
runAsNonRoot: false
|
||||
{{- end }}
|
||||
{{- with (default (dict) $p.scheduling).nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with (default (dict) $p.scheduling).tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: app
|
||||
image: {{ $s.runtime.resolvedImage | quote }}
|
||||
{{- with $s.runtime.command }}
|
||||
command:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with $s.runtime.args }}
|
||||
args:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
ports:
|
||||
{{- toYaml $s.runtime.ports | nindent 12 }}
|
||||
{{- if $s.env }}
|
||||
env:
|
||||
{{- range $name, $value := $s.env }}
|
||||
- name: {{ $name }}
|
||||
value: {{ $value | quote }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
env: []
|
||||
{{- end }}
|
||||
resources:
|
||||
{{- toYaml $p.resources | nindent 12 }}
|
||||
# Pod Security Admission "restricted" is completed after render in manifests.py, so a
|
||||
# chart cannot forget it. Only the container-level opt-out is stated here.
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
{{- $add := list }}
|
||||
{{- if $needsBind }}{{- $add = append $add "NET_BIND_SERVICE" }}{{- end }}
|
||||
{{- if $s.runtime.runAsRoot }}
|
||||
{{- /* A stock root image chowns its state and then drops its workers to a service
|
||||
user; without these it starts as root and dies on the first chown. The set is
|
||||
fixed by the platform, not reachable from a spec - see manifests.py. */}}
|
||||
{{- $add = concat $add (list "CHOWN" "DAC_OVERRIDE" "FOWNER" "FSETID" "KILL" "SETGID" "SETUID") }}
|
||||
{{- end }}
|
||||
{{- with $add }}
|
||||
capabilities:
|
||||
add:
|
||||
{{- toYaml . | nindent 16 }}
|
||||
{{- end }}
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: {{ $s.healthCheck.path | quote }}
|
||||
port: {{ $s.healthCheck.port }}
|
||||
initialDelaySeconds: {{ $s.healthCheck.initialDelaySeconds }}
|
||||
35
templates/charts/generic-http-service/templates/ingress.yaml
Normal file
35
templates/charts/generic-http-service/templates/ingress.yaml
Normal file
@@ -0,0 +1,35 @@
|
||||
{{- $s := .Values.spec -}}
|
||||
{{- $p := .Values.platform -}}
|
||||
{{- if $s.exposure.public -}}
|
||||
{{- $i := $p.ingress -}}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ $p.name }}
|
||||
namespace: {{ $p.namespace }}
|
||||
labels:
|
||||
{{- toYaml $p.labels | nindent 4 }}
|
||||
annotations:
|
||||
{{- toYaml $p.annotations | nindent 4 }}
|
||||
# cert-manager watches this and issues a Let's Encrypt certificate into tls.secretName.
|
||||
cert-manager.io/cluster-issuer: {{ $i.clusterIssuer | quote }}
|
||||
nginx.ingress.kubernetes.io/ssl-redirect: "true"
|
||||
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
|
||||
spec:
|
||||
ingressClassName: {{ $i.className | quote }}
|
||||
tls:
|
||||
- hosts:
|
||||
- {{ $i.host | quote }}
|
||||
secretName: {{ $p.name }}-tls
|
||||
rules:
|
||||
- host: {{ $i.host | quote }}
|
||||
http:
|
||||
paths:
|
||||
- path: {{ $s.exposure.path | quote }}
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: {{ $p.name }}
|
||||
port:
|
||||
number: {{ $p.servicePort }}
|
||||
{{- end }}
|
||||
15
templates/charts/generic-http-service/templates/service.yaml
Normal file
15
templates/charts/generic-http-service/templates/service.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
{{- $s := .Values.spec -}}
|
||||
{{- $p := .Values.platform -}}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ $p.name }}
|
||||
namespace: {{ $p.namespace }}
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
{{- toYaml $p.selector | nindent 4 }}
|
||||
ports:
|
||||
- name: http
|
||||
port: {{ $p.servicePort }}
|
||||
targetPort: {{ (index $s.runtime.ports 0).name }}
|
||||
8
templates/charts/generic-http-service/values.yaml
Normal file
8
templates/charts/generic-http-service/values.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
# Defaults only. Every render supplies both layers explicitly:
|
||||
# spec.* — the user's, projected from a schema-validated resolvedSpec
|
||||
# platform.* — the gateway's, derived from platform config and never reachable from a spec
|
||||
#
|
||||
# Disjoint roots are deliberate: a spec cannot name a platform value at all, which is a stronger
|
||||
# guarantee than relying on merge order.
|
||||
spec: {}
|
||||
platform: {}
|
||||
Reference in New Issue
Block a user