-
Notifications
You must be signed in to change notification settings - Fork 123
CP/DP Split: Add agent/nginx container and deployment #2958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sjberman
merged 2 commits into
change/control-data-plane-split
from
chore/agent-container
Jan 2, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
|
||
set -euxo pipefail | ||
|
||
handle_term() { | ||
echo "received TERM signal" | ||
echo "stopping nginx-agent ..." | ||
kill -TERM "${agent_pid}" 2>/dev/null | ||
echo "stopping nginx ..." | ||
kill -TERM "${nginx_pid}" 2>/dev/null | ||
} | ||
|
||
trap 'handle_term' TERM | ||
|
||
rm -rf /var/run/nginx/*.sock | ||
|
||
# Launch nginx | ||
echo "starting nginx ..." | ||
/usr/sbin/nginx -g "daemon off;" & | ||
|
||
nginx_pid=$! | ||
|
||
SECONDS=0 | ||
|
||
while ! ps -ef | grep "nginx: master process" | grep -v grep; do | ||
if ((SECONDS > 5)); then | ||
echo "couldn't find nginx master process" | ||
exit 1 | ||
fi | ||
done | ||
|
||
# start nginx-agent, pass args | ||
echo "starting nginx-agent ..." | ||
nginx-agent "$@" & | ||
|
||
agent_pid=$! | ||
|
||
if [ $? != 0 ]; then | ||
echo "couldn't start the agent, please check the log file" | ||
exit 1 | ||
fi | ||
|
||
wait_term() { | ||
wait ${agent_pid} | ||
trap - TERM | ||
kill -QUIT "${nginx_pid}" 2>/dev/null | ||
echo "waiting for nginx to stop..." | ||
wait ${nginx_pid} | ||
} | ||
|
||
wait_term | ||
|
||
echo "nginx-agent process has stopped, exiting." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
charts/nginx-gateway-fabric/templates/tmp-nginx-agent-conf.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: nginx-agent-config | ||
namespace: {{ .Release.Namespace }} | ||
data: | ||
nginx-agent.conf: |- | ||
command: | ||
server: | ||
host: {{ include "nginx-gateway.fullname" . }}.{{ .Release.Namespace }}.svc | ||
port: 443 | ||
allowed_directories: | ||
- /etc/nginx | ||
- /usr/share/nginx | ||
- /var/run/nginx | ||
features: | ||
- connection | ||
log: | ||
level: debug |
186 changes: 186 additions & 0 deletions
186
charts/nginx-gateway-fabric/templates/tmp-nginx-deployment.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: tmp-nginx-deployment | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: tmp-nginx-deployment | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: tmp-nginx-deployment | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
spec: | ||
initContainers: | ||
- name: sleep # wait for a bit for control plane to be ready | ||
image: {{ .Values.nginxGateway.image.repository }}:{{ default .Chart.AppVersion .Values.nginxGateway.image.tag }} | ||
imagePullPolicy: {{ .Values.nginxGateway.image.pullPolicy }} | ||
command: | ||
- /usr/bin/gateway | ||
- sleep | ||
- --duration=15s | ||
- name: init | ||
image: {{ .Values.nginxGateway.image.repository }}:{{ default .Chart.AppVersion .Values.nginxGateway.image.tag }} | ||
imagePullPolicy: {{ .Values.nginxGateway.image.pullPolicy }} | ||
command: | ||
- /usr/bin/gateway | ||
- initialize | ||
- --source | ||
- /includes/main.conf | ||
{{- if .Values.nginx.plus }} | ||
- --source | ||
- /includes/mgmt.conf | ||
- --nginx-plus | ||
{{- end }} | ||
- --destination | ||
- /etc/nginx/main-includes | ||
env: | ||
- name: POD_UID | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.uid | ||
securityContext: | ||
seccompProfile: | ||
type: RuntimeDefault | ||
capabilities: | ||
drop: | ||
- ALL | ||
readOnlyRootFilesystem: true | ||
runAsUser: 102 | ||
runAsGroup: 1001 | ||
volumeMounts: | ||
- name: nginx-includes-bootstrap | ||
mountPath: /includes | ||
- name: nginx-main-includes | ||
mountPath: /etc/nginx/main-includes | ||
containers: | ||
- image: {{ .Values.nginx.image.repository }}:{{ .Values.nginx.image.tag | default .Chart.AppVersion }} | ||
imagePullPolicy: {{ .Values.nginx.image.pullPolicy }} | ||
name: nginx | ||
{{- if .Values.nginx.lifecycle }} | ||
lifecycle: | ||
{{- toYaml .Values.nginx.lifecycle | nindent 10 }} | ||
{{- end }} | ||
ports: | ||
- containerPort: 80 | ||
name: http | ||
- containerPort: 443 | ||
name: https | ||
securityContext: | ||
seccompProfile: | ||
type: RuntimeDefault | ||
allowPrivilegeEscalation: {{ .Values.nginx.securityContext.allowPrivilegeEscalation }} | ||
capabilities: | ||
add: | ||
- NET_BIND_SERVICE | ||
drop: | ||
- ALL | ||
readOnlyRootFilesystem: true | ||
runAsUser: 101 | ||
runAsGroup: 1001 | ||
volumeMounts: | ||
- name: nginx-agent | ||
mountPath: /etc/nginx-agent | ||
- name: nginx-conf | ||
mountPath: /etc/nginx/conf.d | ||
- name: nginx-stream-conf | ||
mountPath: /etc/nginx/stream-conf.d | ||
- name: nginx-main-includes | ||
mountPath: /etc/nginx/main-includes | ||
- name: nginx-secrets | ||
mountPath: /etc/nginx/secrets | ||
- name: nginx-run | ||
mountPath: /var/run/nginx | ||
- name: nginx-cache | ||
mountPath: /var/cache/nginx | ||
- name: nginx-includes | ||
mountPath: /etc/nginx/includes | ||
{{- if .Values.nginx.plus }} | ||
- name: nginx-lib | ||
mountPath: /var/lib/nginx/state | ||
{{- if .Values.nginx.usage.secretName }} | ||
- name: nginx-plus-license | ||
mountPath: /etc/nginx/license.jwt | ||
subPath: license.jwt | ||
{{- end }} | ||
{{- if or .Values.nginx.usage.caSecretName .Values.nginx.usage.clientSSLSecretName }} | ||
- name: nginx-plus-usage-certs | ||
mountPath: /etc/nginx/certs-bootstrap/ | ||
{{- end }} | ||
{{- end }} | ||
{{- with .Values.nginx.extraVolumeMounts -}} | ||
{{ toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.nginx.debug }} | ||
command: | ||
- "/bin/sh" | ||
args: | ||
- "-c" | ||
- "rm -rf /var/run/nginx/*.sock && nginx-debug -g 'daemon off;'" | ||
{{- end }} | ||
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} | ||
{{- if .Values.affinity }} | ||
affinity: | ||
{{- toYaml .Values.affinity | nindent 8 }} | ||
{{- end }} | ||
serviceAccountName: {{ include "nginx-gateway.serviceAccountName" . }} | ||
securityContext: | ||
fsGroup: 1001 | ||
runAsNonRoot: true | ||
{{- if .Values.tolerations }} | ||
tolerations: | ||
{{- toYaml .Values.tolerations | nindent 6 }} | ||
{{- end }} | ||
{{- if .Values.nodeSelector }} | ||
nodeSelector: | ||
{{- toYaml .Values.nodeSelector | nindent 8 }} | ||
{{- end }} | ||
volumes: | ||
- name: nginx-agent | ||
configMap: | ||
name: nginx-agent-config | ||
- name: nginx-conf | ||
emptyDir: {} | ||
- name: nginx-stream-conf | ||
emptyDir: {} | ||
- name: nginx-main-includes | ||
emptyDir: {} | ||
- name: nginx-secrets | ||
emptyDir: {} | ||
- name: nginx-run | ||
emptyDir: {} | ||
- name: nginx-cache | ||
emptyDir: {} | ||
- name: nginx-includes | ||
emptyDir: {} | ||
- name: nginx-includes-bootstrap | ||
configMap: | ||
name: nginx-includes-bootstrap | ||
{{- if .Values.nginx.plus }} | ||
- name: nginx-lib | ||
emptyDir: {} | ||
{{- if .Values.nginx.usage.secretName }} | ||
- name: nginx-plus-license | ||
secret: | ||
secretName: {{ .Values.nginx.usage.secretName }} | ||
{{- end }} | ||
{{- if or .Values.nginx.usage.caSecretName .Values.nginx.usage.clientSSLSecretName }} | ||
- name: nginx-plus-usage-certs | ||
projected: | ||
sources: | ||
{{- if .Values.nginx.usage.caSecretName }} | ||
- secret: | ||
name: {{ .Values.nginx.usage.caSecretName }} | ||
{{- end }} | ||
{{- if .Values.nginx.usage.clientSSLSecretName }} | ||
- secret: | ||
name: {{ .Values.nginx.usage.clientSSLSecretName }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
{{- with .Values.extraVolumes -}} | ||
{{ toYaml . | nindent 6 }} | ||
{{- end }} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.