Skip to content
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

zero: add kustomize #4

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions zero/kustomize/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pomerium-secret.yaml
43 changes: 43 additions & 0 deletions zero/kustomize/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Installing Pomerium Zero

Visit https://console.pomerium.app and register for an account.

# Install base pomerium zero

```shell
kubectl apply -k https://github.com/pomerium/pomerium/k8s/zero?ref=main
```

(that would install an evergreen `main`)

# Create a secret with Pomerium Zero token to complete your installation

```yaml filename="pomerium-secret.yaml"
apiVersion: v1
kind: Secret
metadata:
name: pomerium
namespace: pomerium-zero
type: Opaque
stringData:
pomerium_zero_token:
```

```shell
kubectl apply -f pomerium-secret.yaml
```

Now your Pomerium deployment should be up and running.

# Update Pomerium cluster configuration

1. The externally available address of your Pomerium Cluster should be set to the value assigned by your Load Balancer:

```shell
kubectl get svc/pomerium-proxy -n pomerium-zero -o=jsonpath='{.status.loadBalancer.ingress[0].ip}'
```

2. Because container is configured to run as non-root, the following should be adjusted:

- http redirect address set to `:8080`
- server address set to `:8443`
16 changes: 16 additions & 0 deletions zero/kustomize/deployment/base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: pomerium
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: pomerium-zero
template:
spec:
automountServiceAccountToken: true
serviceAccountName: pomerium-zero
containers:
- name: pomerium
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: pomerium
- name: pomerium
readinessProbe:
httpGet:
path: /healthz
port: 80
initialDelaySeconds: 10
periodSeconds: 5
livenessProbe:
httpGet:
path: /healthz
port: 80
initialDelaySeconds: 15
periodSeconds: 10

Not sure this maps to true readyness /live however....

terminationGracePeriodSeconds: 10
29 changes: 29 additions & 0 deletions zero/kustomize/deployment/env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: pomerium
spec:
template:
spec:
containers:
- name: pomerium
env:
- name: POMERIUM_ZERO_TOKEN
valueFrom:
secretKeyRef:
name: pomerium
key: pomerium_zero_token
optional: false
- name: POMERIUM_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: BOOTSTRAP_CONFIG_FILE
value: "/var/run/secrets/pomerium/bootstrap.dat"
- name: BOOTSTRAP_CONFIG_WRITEBACK_URI
value: "secret://$(POMERIUM_NAMESPACE)/pomerium/bootstrap"
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
12 changes: 12 additions & 0 deletions zero/kustomize/deployment/image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: pomerium
spec:
replicas: 1
template:
spec:
containers:
- name: pomerium
image: pomerium/pomerium:v0.27.2
imagePullPolicy: IfNotPresent
10 changes: 10 additions & 0 deletions zero/kustomize/deployment/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resources:
- base.yaml
patchesStrategicMerge:
- env.yaml
- image.yaml
- ports.yaml
- resources.yaml
- no-root.yaml
- readonly-root-fs.yaml
- volumes.yaml
22 changes: 22 additions & 0 deletions zero/kustomize/deployment/no-root.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: pomerium
spec:
template:
spec:
securityContext:
fsGroup: 1000
runAsNonRoot: true
runAsGroup: 1000
runAsUser: 1000
sysctls:
- name: net.ipv4.ip_unprivileged_port_start
Copy link
Contributor

@desimone desimone Oct 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to include port 443 here as well? Consider adding a comment explaining why certain ports are prioritized.

value: "80"
containers:
- name: pomerium
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
19 changes: 19 additions & 0 deletions zero/kustomize/deployment/ports.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: pomerium
spec:
template:
spec:
containers:
- name: pomerium
ports:
- containerPort: 443
name: https
protocol: TCP
- name: http
containerPort: 80
protocol: TCP
- name: metrics
containerPort: 9090
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider explaining what each port is for (especially 80 and 9090 being for redirect and metrics)

protocol: TCP
11 changes: 11 additions & 0 deletions zero/kustomize/deployment/readonly-root-fs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: pomerium
spec:
template:
spec:
containers:
- name: pomerium
securityContext:
readOnlyRootFilesystem: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a comment explaining why this is important for security

16 changes: 16 additions & 0 deletions zero/kustomize/deployment/resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: pomerium
spec:
template:
spec:
containers:
- name: pomerium
resources:
Copy link
Contributor

@desimone desimone Oct 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide additional context on these resources? A comment explaining their purpose and how they’re used here and why they are the defaults would be helpful.

limits:
cpu: 5000m
memory: 1Gi
requests:
cpu: 300m
memory: 200Mi
35 changes: 35 additions & 0 deletions zero/kustomize/deployment/volumes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: pomerium
spec:
template:
spec:
nodeSelector:
kubernetes.io/os: linux
containers:
- name: pomerium
env:
- name: TMPDIR
value: "/tmp/pomerium"
Copy link
Contributor

@desimone desimone Oct 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment explaining the purpose of each tmp folder? Having multiple makes the structure unclear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

various parts of stdlib and other libraries we use make use of TMPDIR and XDG_CACHE

- name: XDG_CACHE_HOME
value: "/tmp/pomerium/cache"
- name: XDG_DATA_HOME
value: "/tmp/pomerium/cache"
volumeMounts:
- mountPath: "/tmp/pomerium"
name: tmp
- mountPath: "/var/run/secrets/pomerium"
name: bootstrap
readOnly: true
volumes:
- name: tmp
emptyDir:
sizeLimit: 500Mi
- name: bootstrap
secret:
optional: true
secretName: pomerium
items:
- key: bootstrap
path: bootstrap.dat
8 changes: 8 additions & 0 deletions zero/kustomize/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace: pomerium-zero
commonLabels:
app.kubernetes.io/name: pomerium-zero
resources:
- namespace.yaml
- ./rbac
- ./deployment
- ./service
4 changes: 4 additions & 0 deletions zero/kustomize/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: pomerium-zero
8 changes: 8 additions & 0 deletions zero/kustomize/pomerium-secret.yaml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: pomerium
namespace: pomerium-zero
type: Opaque
stringData:
pomerium_zero_token: YOUR_TOKEN_HERE
6 changes: 6 additions & 0 deletions zero/kustomize/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- role.yaml
- role_binding.yaml
- service_account.yaml
14 changes: 14 additions & 0 deletions zero/kustomize/rbac/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: pomerium-zero
rules:
- apiGroups:
- ""
resources:
- secrets
verbs:
- patch
resourceNames:
- pomerium
11 changes: 11 additions & 0 deletions zero/kustomize/rbac/role_binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: pomerium-zero
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: pomerium-zero
subjects:
- kind: ServiceAccount
name: pomerium-zero
4 changes: 4 additions & 0 deletions zero/kustomize/rbac/service_account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: pomerium-zero
2 changes: 2 additions & 0 deletions zero/kustomize/service/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- proxy.yaml
16 changes: 16 additions & 0 deletions zero/kustomize/service/proxy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: pomerium-proxy
spec:
type: LoadBalancer
externalTrafficPolicy: Local
ports:
- port: 443
targetPort: https
protocol: TCP
name: https
- name: http
targetPort: http
protocol: TCP
port: 80