Skip to content

Long-running service

A Deployment, ClusterIP Service and Ingress that pass Kestrel’s admission rules. nginxinc/nginx-unprivileged stands in for your app: replace the image, port and resources. Commit the manifests to the path your ArgoCD Application syncs (for example manifests/my-service/) and replace <tenant>.

Before you start:

  • Create the namespace: kubectl create namespace <tenant>-prod.
  • Ask RCS (ticket) for a DNS record for my-service.<tenant>.kestrel.arbutus.cloud, and to enable certificates for your tenant if that isn’t done yet. Creating an Ingress does neither. See Ingress and TLS.

Kyverno enforces the PodSecurity restricted profile on every Pod, so keep the securityContext fields. readOnlyRootFilesystem is optional hardening; it is why nginx gets three emptyDir mounts.

One replica, no probes, and uber-user-significant, which never preempts other Pods.

manifests/my-service/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-service
namespace: <tenant>-prod
spec:
replicas: 1
selector:
matchLabels:
app: my-service
template:
metadata:
labels:
app: my-service
spec:
priorityClassName: uber-user-significant
securityContext:
runAsNonRoot: true
runAsUser: 101
seccompProfile:
type: RuntimeDefault
containers:
- name: nginx
image: nginxinc/nginx-unprivileged:1.27-alpine
ports:
- containerPort: 8080
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: [ALL]
resources:
requests:
cpu: 100m
memory: 64Mi
limits:
cpu: 200m
memory: 128Mi
volumeMounts:
- name: tmp
mountPath: /tmp
- name: cache
mountPath: /var/cache/nginx
- name: run
mountPath: /var/run
volumes:
- name: tmp
emptyDir: {}
- name: cache
emptyDir: {}
- name: run
emptyDir: {}

Cinder volumes are ReadWriteOnce: one node at a time. A Deployment that mounts one needs a single replica and the Recreate strategy; with the default RollingUpdate, a new Pod that lands on another node stalls with Multi-Attach error. For more than one replica, use a StatefulSet. The fresh volume is root:root 0755, so set fsGroup too. Merge these fields into the Minimal manifest:

spec:
replicas: 1
strategy:
type: Recreate # RWO volume: the old Pod must release it first
template:
spec:
securityContext:
fsGroup: 101 # makes the volume writable for nginx (UID/GID 101)
fsGroupChangePolicy: OnRootMismatch
containers:
- name: nginx
volumeMounts:
- name: data
mountPath: /data
volumes:
- name: data
persistentVolumeClaim:
claimName: my-service-data

See Storage classes and Persistent volumes.

manifests/my-service/service.yaml
apiVersion: v1
kind: Service
metadata:
name: my-service
namespace: <tenant>-prod
spec:
type: ClusterIP
selector:
app: my-service
ports:
- port: 80
targetPort: 8080
manifests/my-service/ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-service
namespace: <tenant>-prod
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
traefik.ingress.kubernetes.io/router.entrypoints: websecure
traefik.ingress.kubernetes.io/router.tls: "true"
spec:
ingressClassName: traefik
tls:
- hosts:
- my-service.<tenant>.kestrel.arbutus.cloud
secretName: my-service-tls
rules:
- host: my-service.<tenant>.kestrel.arbutus.cloud
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-service
port:
number: 80
  • Services must be ClusterIP. LoadBalancer, NodePort and ExternalName are denied; see Service types.
  • The websecure entrypoint makes the route HTTPS-only: http:// returns 404.
  • While testing, use letsencrypt-staging (browsers will warn about its certificates). The Let’s Encrypt rate limit for arbutus.cloud is shared by every tenant; see TLS.
Terminal window
kubectl get pods,svc,ingress,certificate -n <tenant>-prod
kubectl logs -n <tenant>-prod deployment/my-service
curl -I https://my-service.<tenant>.kestrel.arbutus.cloud/

The Certificate my-service-tls can be READY: True before the hostname resolves, because cert-manager validates it with DNS01 against RCS’s DNS, not over HTTP. The URL works once RCS has created the DNS record.

SymptomCause and fix
Application Synced, but no Pods; kubectl describe rs -n <tenant>-prod shows a validate.kyverno.svc-fail PodSecurity denialA required securityContext field is missing. The denial appears only in the ReplicaSet’s events, not in ArgoCD or on the Deployment.
Pod Pending with Insufficient cpu or Insufficient memoryNo node has room. This is node capacity, not quota. The anti-affinity rule is preferred, so it never blocks scheduling.
New Pod stuck in ContainerCreating with Multi-Attach errorThe Deployment mounts an RWO volume with RollingUpdate. Use the Recreate strategy (see above).

For other messages, see the Troubleshooting index.