Skip to content

Commit

Permalink
Add conditional to RBAC and generate new manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
ciarams87 committed Feb 15, 2024
1 parent 949c08e commit 244391d
Show file tree
Hide file tree
Showing 8 changed files with 617 additions and 29 deletions.
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,17 @@ generate-crds: ## Generate CRDs and Go types using kubebuilder
go run sigs.k8s.io/controller-tools/cmd/controller-gen object paths=./apis/...

.PHONY: generate-manifests
generate-manifests: generate-manifests-plus ## Generate manifests using Helm.
generate-manifests: ## Generate manifests using Helm.
cp $(CHART_DIR)/crds/* $(MANIFEST_DIR)/crds/
helm template nginx-gateway $(CHART_DIR) $(HELM_TEMPLATE_COMMON_ARGS) $(HELM_TEMPLATE_EXTRA_ARGS_FOR_ALL_MANIFESTS_FILE) -n nginx-gateway | cat $(strip $(MANIFEST_DIR))/namespace.yaml - > $(strip $(MANIFEST_DIR))/nginx-gateway.yaml
helm template nginx-gateway $(CHART_DIR) $(HELM_TEMPLATE_COMMON_ARGS) $(HELM_TEMPLATE_EXTRA_ARGS_FOR_ALL_MANIFESTS_FILE) --set nginx.plus=true --set nginx.image.repository=$(NGINX_PLUS_PREFIX) -n nginx-gateway | cat $(strip $(MANIFEST_DIR))/namespace.yaml - > $(strip $(MANIFEST_DIR))/nginx-plus-gateway.yaml
helm template nginx-gateway $(CHART_DIR) $(HELM_TEMPLATE_COMMON_ARGS) $(HELM_TEMPLATE_EXTRA_ARGS_FOR_ALL_MANIFESTS_FILE) --set nginxGateway.gwAPIExperimentalFeatures.enable=true -n nginx-gateway | cat $(strip $(MANIFEST_DIR))/namespace.yaml - > $(strip $(MANIFEST_DIR))/nginx-gateway-experimental.yaml
helm template nginx-gateway $(CHART_DIR) $(HELM_TEMPLATE_COMMON_ARGS) $(HELM_TEMPLATE_EXTRA_ARGS_FOR_ALL_MANIFESTS_FILE) --set nginxGateway.gwAPIExperimentalFeatures.enable=true --set nginx.plus=true --set nginx.image.repository=$(NGINX_PLUS_PREFIX) -n nginx-gateway | cat $(strip $(MANIFEST_DIR))/namespace.yaml - > $(strip $(MANIFEST_DIR))/nginx-plus-gateway-experimental.yaml
helm template nginx-gateway $(CHART_DIR) $(HELM_TEMPLATE_COMMON_ARGS) --set metrics.enable=false -n nginx-gateway -s templates/deployment.yaml > conformance/provisioner/static-deployment.yaml
helm template nginx-gateway $(CHART_DIR) $(HELM_TEMPLATE_COMMON_ARGS) -n nginx-gateway -s templates/service.yaml > $(strip $(MANIFEST_DIR))/service/loadbalancer.yaml
helm template nginx-gateway $(CHART_DIR) $(HELM_TEMPLATE_COMMON_ARGS) --set service.annotations.'service\.beta\.kubernetes\.io\/aws-load-balancer-type'="nlb" -n nginx-gateway -s templates/service.yaml > $(strip $(MANIFEST_DIR))/service/loadbalancer-aws-nlb.yaml
helm template nginx-gateway $(CHART_DIR) $(HELM_TEMPLATE_COMMON_ARGS) --set service.type=NodePort --set service.externalTrafficPolicy="" -n nginx-gateway -s templates/service.yaml > $(strip $(MANIFEST_DIR))/service/nodeport.yaml

.PHONY: generate-manifests-plus
generate-manifests-plus: ## Generate manifests using Helm for NGINX Plus.
helm template nginx-gateway $(CHART_DIR) $(HELM_TEMPLATE_COMMON_ARGS) $(HELM_TEMPLATE_EXTRA_ARGS_FOR_ALL_MANIFESTS_FILE) --set nginx.plus=true --set nginx.image.repository=$(NGINX_PLUS_PREFIX) -n nginx-gateway | cat $(strip $(MANIFEST_DIR))/namespace.yaml - > $(strip $(MANIFEST_DIR))/nginx-plus-gateway.yaml

.PHONY: crds-release-file
crds-release-file: ## Generate combined crds file for releases
scripts/combine-crds.sh
Expand Down
6 changes: 6 additions & 0 deletions deploy/helm-chart/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ rules:
- namespaces
- services
- secrets
{{- if .Values.nginxGateway.gwAPIExperimentalFeatures.enable }}
- configmaps
{{- end }}
verbs:
- list
- watch
Expand Down Expand Up @@ -77,7 +79,9 @@ rules:
- gateways
- httproutes
- referencegrants
{{- if .Values.nginxGateway.gwAPIExperimentalFeatures.enable }}
- backendtlspolicies
{{- end }}
verbs:
- list
- watch
Expand All @@ -87,7 +91,9 @@ rules:
- httproutes/status
- gateways/status
- gatewayclasses/status
{{- if .Values.nginxGateway.gwAPIExperimentalFeatures.enable }}
- backendtlspolicies/status
{{- end }}
verbs:
- update
- apiGroups:
Expand Down
291 changes: 291 additions & 0 deletions deploy/manifests/nginx-gateway-experimental.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,291 @@
apiVersion: v1
kind: Namespace
metadata:
name: nginx-gateway
---
# Source: nginx-gateway-fabric/templates/rbac.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: nginx-gateway
namespace: nginx-gateway
labels:
app.kubernetes.io/name: nginx-gateway
app.kubernetes.io/instance: nginx-gateway
app.kubernetes.io/version: "edge"
annotations:
{}
---
# Source: nginx-gateway-fabric/templates/rbac.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: nginx-gateway
labels:
app.kubernetes.io/name: nginx-gateway
app.kubernetes.io/instance: nginx-gateway
app.kubernetes.io/version: "edge"
rules:
- apiGroups:
- ""
resources:
- namespaces
- services
- secrets
- configmaps
verbs:
- list
- watch
# FIXME(bjee19): make nodes, pods, replicasets permission dependent on telemetry being enabled.
# https://github.com/nginxinc/nginx-gateway-fabric/issues/1317.
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- apiGroups:
- ""
resources:
- nodes
verbs:
- list
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- apps
resources:
- replicasets
verbs:
- get
- apiGroups:
- discovery.k8s.io
resources:
- endpointslices
verbs:
- list
- watch
- apiGroups:
- gateway.networking.k8s.io
resources:
- gatewayclasses
- gateways
- httproutes
- referencegrants
- backendtlspolicies
verbs:
- list
- watch
- apiGroups:
- gateway.networking.k8s.io
resources:
- httproutes/status
- gateways/status
- gatewayclasses/status
- backendtlspolicies/status
verbs:
- update
- apiGroups:
- gateway.nginx.org
resources:
- nginxgateways
verbs:
- get
- list
- watch
- apiGroups:
- gateway.nginx.org
resources:
- nginxgateways/status
verbs:
- update
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- get
- update
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs:
- list
- watch
---
# Source: nginx-gateway-fabric/templates/rbac.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: nginx-gateway
labels:
app.kubernetes.io/name: nginx-gateway
app.kubernetes.io/instance: nginx-gateway
app.kubernetes.io/version: "edge"
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: nginx-gateway
subjects:
- kind: ServiceAccount
name: nginx-gateway
namespace: nginx-gateway
---
# Source: nginx-gateway-fabric/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-gateway
namespace: nginx-gateway
labels:
app.kubernetes.io/name: nginx-gateway
app.kubernetes.io/instance: nginx-gateway
app.kubernetes.io/version: "edge"
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: nginx-gateway
app.kubernetes.io/instance: nginx-gateway
template:
metadata:
labels:
app.kubernetes.io/name: nginx-gateway
app.kubernetes.io/instance: nginx-gateway
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9113"
spec:
containers:
- args:
- static-mode
- --gateway-ctlr-name=gateway.nginx.org/nginx-gateway-controller
- --gatewayclass=nginx
- --config=nginx-gateway-config
- --service=nginx-gateway
- --metrics-port=9113
- --health-port=8081
- --leader-election-lock-name=nginx-gateway-leader-election
- --gateway-api-experimental-features
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
image: ghcr.io/nginxinc/nginx-gateway-fabric:edge
imagePullPolicy: Always
name: nginx-gateway
ports:
- name: metrics
containerPort: 9113
- name: health
containerPort: 8081
readinessProbe:
httpGet:
path: /readyz
port: health
initialDelaySeconds: 3
periodSeconds: 1
securityContext:
allowPrivilegeEscalation: false
capabilities:
add:
- KILL
drop:
- ALL
readOnlyRootFilesystem: true
runAsUser: 102
runAsGroup: 1001
volumeMounts:
- name: nginx-conf
mountPath: /etc/nginx/conf.d
- name: nginx-secrets
mountPath: /etc/nginx/secrets
- name: nginx-run
mountPath: /var/run/nginx
- image: ghcr.io/nginxinc/nginx-gateway-fabric/nginx:edge
imagePullPolicy: Always
name: nginx
ports:
- containerPort: 80
name: http
- containerPort: 443
name: https
securityContext:
capabilities:
add:
- NET_BIND_SERVICE
drop:
- ALL
readOnlyRootFilesystem: true
runAsUser: 101
runAsGroup: 1001
volumeMounts:
- name: nginx-conf
mountPath: /etc/nginx/conf.d
- name: nginx-secrets
mountPath: /etc/nginx/secrets
- name: nginx-run
mountPath: /var/run/nginx
- name: nginx-cache
mountPath: /var/cache/nginx
- name: nginx-lib
mountPath: /var/lib/nginx
terminationGracePeriodSeconds: 30
serviceAccountName: nginx-gateway
shareProcessNamespace: true
securityContext:
fsGroup: 1001
runAsNonRoot: true
volumes:
- name: nginx-conf
emptyDir: {}
- name: nginx-secrets
emptyDir: {}
- name: nginx-run
emptyDir: {}
- name: nginx-cache
emptyDir: {}
- name: nginx-lib
emptyDir: {}
---
# Source: nginx-gateway-fabric/templates/gatewayclass.yaml
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: nginx
labels:
app.kubernetes.io/name: nginx-gateway
app.kubernetes.io/instance: nginx-gateway
app.kubernetes.io/version: "edge"
spec:
controllerName: gateway.nginx.org/nginx-gateway-controller
---
# Source: nginx-gateway-fabric/templates/nginxgateway.yaml
apiVersion: gateway.nginx.org/v1alpha1
kind: NginxGateway
metadata:
name: nginx-gateway-config
namespace: nginx-gateway
labels:
app.kubernetes.io/name: nginx-gateway
app.kubernetes.io/instance: nginx-gateway
app.kubernetes.io/version: "edge"
spec:
logging:
level: info
3 changes: 0 additions & 3 deletions deploy/manifests/nginx-gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ rules:
- namespaces
- services
- secrets
- configmaps
verbs:
- list
- watch
Expand Down Expand Up @@ -77,7 +76,6 @@ rules:
- gateways
- httproutes
- referencegrants
- backendtlspolicies
verbs:
- list
- watch
Expand All @@ -87,7 +85,6 @@ rules:
- httproutes/status
- gateways/status
- gatewayclasses/status
- backendtlspolicies/status
verbs:
- update
- apiGroups:
Expand Down
Loading

0 comments on commit 244391d

Please sign in to comment.