diff --git a/deploy/diagnostic-gateway/render-proxy.py b/deploy/diagnostic-gateway/render-proxy.py index 50b89964..85f17da9 100644 --- a/deploy/diagnostic-gateway/render-proxy.py +++ b/deploy/diagnostic-gateway/render-proxy.py @@ -4,6 +4,6 @@ image=sys.argv[1] if '@sha256:' not in image: raise SystemExit('immutable image required') ns='droboticflow-fanyu' def resource(kind,name,spec): return {'apiVersion':'apps/v1' if kind=='Deployment' else 'v1','kind':kind,'metadata':{'name':name,'namespace':ns},**spec} -items=[resource('ConfigMap','diagnostic-edge',{'data':{'nginx.conf':Path(__file__).with_name('nginx.conf').read_text()}}),resource('Deployment','diagnostic-edge',{'spec':{'replicas':2,'selector':{'matchLabels':{'app':'diagnostic-edge'}},'template':{'metadata':{'labels':{'app':'diagnostic-edge'}},'spec':{'automountServiceAccountToken':False,'securityContext':{'runAsUser':101,'runAsGroup':101,'runAsNonRoot':True,'fsGroup':101,'seccompProfile':{'type':'RuntimeDefault'}},'topologySpreadConstraints':[{'maxSkew':1,'topologyKey':'kubernetes.io/hostname','whenUnsatisfiable':'ScheduleAnyway','labelSelector':{'matchLabels':{'app':'diagnostic-edge'}}}],'containers':[{'name':'proxy','image':image,'command':['nginx','-g','daemon off;'],'ports':[{'containerPort':8080},{'containerPort':8443}],'resources':{'requests':{'cpu':'50m','memory':'32Mi'},'limits':{'cpu':'250m','memory':'128Mi'}},'securityContext':{'readOnlyRootFilesystem':True,'allowPrivilegeEscalation':False,'capabilities':{'drop':['ALL']}},'volumeMounts':[{'name':'config','mountPath':'/etc/nginx/nginx.conf','subPath':'nginx.conf','readOnly':True},{'name':'tls','mountPath':'/tls','readOnly':True},{'name':'tmp','mountPath':'/tmp'}],'readinessProbe':{'tcpSocket':{'port':8443}},'livenessProbe':{'tcpSocket':{'port':8443}}}],'volumes':[{'name':'config','configMap':{'name':'diagnostic-edge'}},{'name':'tls','secret':{'secretName':'diagnostic-edge-tls','defaultMode':288}},{'name':'tmp','emptyDir':{'sizeLimit':'128Mi'}}]}}}})] +items=[resource('ConfigMap','diagnostic-edge',{'data':{'nginx.conf':Path(__file__).with_name('nginx.conf').read_text()}}),resource('Deployment','diagnostic-edge',{'spec':{'replicas':2,'selector':{'matchLabels':{'app':'diagnostic-edge'}},'template':{'metadata':{'labels':{'app':'diagnostic-edge'}},'spec':{'imagePullSecrets':[{'name':'droboticflow-registry'}],'automountServiceAccountToken':False,'securityContext':{'runAsUser':101,'runAsGroup':101,'runAsNonRoot':True,'fsGroup':101,'seccompProfile':{'type':'RuntimeDefault'}},'topologySpreadConstraints':[{'maxSkew':1,'topologyKey':'kubernetes.io/hostname','whenUnsatisfiable':'ScheduleAnyway','labelSelector':{'matchLabels':{'app':'diagnostic-edge'}}}],'containers':[{'name':'proxy','image':image,'command':['nginx','-g','daemon off;'],'ports':[{'containerPort':8080},{'containerPort':8443}],'resources':{'requests':{'cpu':'50m','memory':'32Mi'},'limits':{'cpu':'250m','memory':'128Mi'}},'securityContext':{'readOnlyRootFilesystem':True,'allowPrivilegeEscalation':False,'capabilities':{'drop':['ALL']}},'volumeMounts':[{'name':'config','mountPath':'/etc/nginx/nginx.conf','subPath':'nginx.conf','readOnly':True},{'name':'tls','mountPath':'/tls','readOnly':True},{'name':'tmp','mountPath':'/tmp'}],'readinessProbe':{'tcpSocket':{'port':8443}},'livenessProbe':{'tcpSocket':{'port':8443}}}],'volumes':[{'name':'config','configMap':{'name':'diagnostic-edge'}},{'name':'tls','secret':{'secretName':'diagnostic-edge-tls','defaultMode':288}},{'name':'tmp','emptyDir':{'sizeLimit':'128Mi'}}]}}}})] items.append({'apiVersion':'networking.k8s.io/v1','kind':'NetworkPolicy','metadata':{'name':'diagnostic-gateway-ingress','namespace':ns},'spec':{'podSelector':{'matchLabels':{'app':'diagnostic-gateway'}},'policyTypes':['Ingress'],'ingress':[{'from':[{'podSelector':{'matchLabels':{'app':'diagnostic-edge'}}}],'ports':[{'protocol':'TCP','port':8080}]}]}}) print(json.dumps({'apiVersion':'v1','kind':'List','items':items})) diff --git a/k8s/diagnostic-gateway.yaml b/k8s/diagnostic-gateway.yaml index eb833546..8d74160a 100644 --- a/k8s/diagnostic-gateway.yaml +++ b/k8s/diagnostic-gateway.yaml @@ -66,6 +66,8 @@ spec: metadata: labels: {app: diagnostic-gateway} spec: + imagePullSecrets: + - name: droboticflow-registry serviceAccountName: diagnostic-gateway securityContext: runAsNonRoot: true