Nikhil Ch
08/20/2024, 5:33 AMCharith (Cerbos)
Nikhil Ch
08/20/2024, 6:54 AMprathmesh 1
08/20/2024, 6:59 AMCharith (Cerbos)
instance
and it seems to require a NodePort service. So, my hunch is that you might need to change the Cerbos service type to a NodePort to get the ALB working. However, since you're on IPv6, it's probably better to switch the load balancer to ip
mode instead by adding the <http://alb.ingress.kubernetes.io/target-type|alb.ingress.kubernetes.io/target-type>: ip
annotation.prathmesh 1
08/20/2024, 7:34 AMCharith (Cerbos)
Charith (Cerbos)
nishant gupta
08/20/2024, 8:11 AMprathmesh 1
08/20/2024, 8:15 AMapiVersion: <http://networking.k8s.io/v1|networking.k8s.io/v1>
kind: Ingress
metadata:
name: dev-cerbos-ingress
annotations:
<http://alb.ingress.kubernetes.io/actions.ssl-redirect|alb.ingress.kubernetes.io/actions.ssl-redirect>: '{"Type":"redirect","RedirectConfig":{"Protocol":"HTTPS","Port":"443","StatusCode":"HTTP_301"}}'
<http://kubernetes.io/ingress.class|kubernetes.io/ingress.class>: alb
<http://alb.ingress.kubernetes.io/certificate-arn|alb.ingress.kubernetes.io/certificate-arn>: arn
<http://alb.ingress.kubernetes.io/listen-ports|alb.ingress.kubernetes.io/listen-ports>: '[{"HTTPS": 443}]'
<http://alb.ingress.kubernetes.io/scheme|alb.ingress.kubernetes.io/scheme>: internet-facing
<http://alb.ingress.kubernetes.io/ip-address-type|alb.ingress.kubernetes.io/ip-address-type>: dualstack
<http://alb.ingress.kubernetes.io/target-type|alb.ingress.kubernetes.io/target-type>: ip
spec:
rules:
- http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: cerbos
port:
number: 80
Charith (Cerbos)
nishant gupta
08/20/2024, 8:20 AMnishant gupta
08/20/2024, 8:20 AMnishant gupta
08/20/2024, 8:20 AMnishant gupta
08/20/2024, 8:20 AMCharith (Cerbos)
nishant gupta
08/20/2024, 8:21 AMnishant gupta
08/20/2024, 8:22 AMnishant gupta
08/20/2024, 8:22 AMnishant gupta
08/20/2024, 8:23 AMnishant gupta
08/20/2024, 8:23 AMnishant gupta
08/20/2024, 8:23 AMnishant gupta
08/20/2024, 8:23 AMCharith (Cerbos)
nishant gupta
08/20/2024, 8:33 AMnishant gupta
08/20/2024, 8:34 AMCharith (Cerbos)
spec.ipFamilyPolicy
or spec.ipFamilies
on the service. Out of curiosity, what's the output of kubectl describe svc cerbos
?
The Cerbos helm chart currently doesn't have a setting to define the IP family so you'd need to patch it with kustomize as described in https://docs.cerbos.dev/cerbos/latest/installation/helm#_customizing_the_manifests.nishant gupta
08/20/2024, 10:00 AMnishant gupta
08/20/2024, 10:00 AMnishant gupta
08/20/2024, 10:02 AMCharith (Cerbos)
nishant gupta
08/20/2024, 10:16 AMnishant gupta
08/20/2024, 10:16 AMnishant gupta
08/20/2024, 10:17 AMnishant gupta
08/20/2024, 10:19 AMCharith (Cerbos)
curl localhost:3592/_cerbos/health
, does that work?Charith (Cerbos)
prathmesh 1
08/20/2024, 10:37 AMec2-user@ip-10-0-0-244:~$ kubectl port-forward svc/cerbos --address 0.0.0.0 8080:80 -n dev-cerbos-namespace-test
Forwarding from 0.0.0.0:8080 -> 3592
Handling connection for 8080
ec2-user@ip-10-0-0-244:~$ curl <http://localhost:8080/_cerbos/health>
{"status":"SERVING"}
Logs -
k logs -f cerbos-7bdbd89ddd-rw7n4 -n dev-cerbos-namespace-test
{"log.level":"info","@timestamp":"2024-08-20T10:26:14.075Z","log.logger":"cerbos.server","message":"maxprocs: Leaving GOMAXPROCS=8: CPU quota undefined"}
{"log.level":"info","@timestamp":"2024-08-20T10:26:14.075Z","log.logger":"cerbos.server","message":"Loading configuration from /config/config.yaml"}
{"log.level":"warn","@timestamp":"2024-08-20T10:26:14.076Z","log.logger":"cerbos.otel","message":"Disabling OTLP traces because neither OTEL_EXPORTER_OTLP_ENDPOINT nor OTEL_EXPORTER_OTLP_TRACES_ENDPOINT is defined"}
{"log.level":"info","@timestamp":"2024-08-20T10:26:14.076Z","log.logger":"cerbos.postgres","message":"Initializing Postgres storage","host":"dev-rds","database":"pdb"}
{"log.level":"info","@timestamp":"2024-08-20T10:26:15.126Z","log.logger":"cerbos.db","message":"Checking database schema. Set skipSchemaCheck to true to disable."}
{"log.level":"info","@timestamp":"2024-08-20T10:26:15.144Z","log.logger":"cerbos.db","message":"Database schema check completed"}
{"log.level":"info","@timestamp":"2024-08-20T10:26:15.145Z","log.logger":"cerbos.telemetry","message":"Anonymous telemetry enabled. Disable via the config file or by setting the CERBOS_NO_TELEMETRY=1 environment variable"}
{"log.level":"info","@timestamp":"2024-08-20T10:26:15.145Z","log.logger":"cerbos.grpc","message":"Starting admin service"}
{"log.level":"info","@timestamp":"2024-08-20T10:26:15.145Z","log.logger":"cerbos.grpc","message":"Starting gRPC server at :3593"}
{"log.level":"info","@timestamp":"2024-08-20T10:26:15.181Z","log.logger":"cerbos.http","message":"Starting HTTP server at :3592"}
Charith (Cerbos)
k describe pod cerbos-7bdbd89ddd-rw7n4 -n dev-cerbos-namespace-test
as well.nishant gupta
08/20/2024, 10:42 AMnishant gupta
08/20/2024, 10:43 AMprathmesh 1
08/20/2024, 10:43 AMk describe pod cerbos-7bdbd89ddd-rw7n4 -n dev-cerbos-namespace-test
Name: cerbos-7bdbd89ddd-rw7n4
Namespace: dev-cerbos-namespace-test
Priority: 0
Service Account: dev-cerbos-sa
Node: ip-10-0-24-229.ap-south-1.compute.internal/2406:da1a:66e:5915::31b7
Start Time: Tue, 20 Aug 2024 10:26:11 +0000
Labels: <http://app.kubernetes.io/instance=cerbos|app.kubernetes.io/instance=cerbos>
<http://app.kubernetes.io/name=cerbos|app.kubernetes.io/name=cerbos>
pod-template-hash=7bdbd89ddd
Annotations: <none>
Status: Running
IP: 2406:da1a:66e:5915:3572::d
IPs:
IP: 2406:da1a:66e:5915:3572::d
Controlled By: ReplicaSet/cerbos-7bdbd89ddd
Containers:
cerbos:
Container ID: <containerd://66cf60394703dea739581b377e7d38d75baa6d2909d11c7b0870c907f8f8273>5
Image: <http://ghcr.io/cerbos/cerbos:0.38.1|ghcr.io/cerbos/cerbos:0.38.1>
Image ID: <http://ghcr.io/cerbos/cerbos@sha256:c3c8736f08f07705ebd6bfa4ae8ede870c68a3f1f1d0ca8526fb456aef1bc20a|ghcr.io/cerbos/cerbos@sha256:c3c8736f08f07705ebd6bfa4ae8ede870c68a3f1f1d0ca8526fb456aef1bc20a>
Port: <none>
Host Port: <none>
Args:
server
--config=/config/config.yaml
--log-level=INFO
State: Running
Started: Tue, 20 Aug 2024 10:26:13 +0000
Ready: True
Restart Count: 0
Environment:
ENVIRONMENT: dev
PGHOST: 10.0.6.116
CERBOS_CONFIG: /config/config.yaml
CERBOS_PASSWORD_HASH: <set to the key 'passwordHash' in secret 'cerbos-secret'> Optional: false
CERBOS_USERNAME: <set to the key 'username' in secret 'cerbos-secret'> Optional: false
POSTGRES_USERNAME: <set to the key 'postgresUser' in secret 'cerbos-secret'> Optional: false
POSTGRES_PASSWORD: <set to the key 'postgresPassword' in secret 'cerbos-secret'> Optional: false
AWS_STS_REGIONAL_ENDPOINTS: regional
AWS_DEFAULT_REGION: ap-south-1
AWS_REGION: ap-south-1
AWS_ROLE_ARN: arn:aws:iam::339712719004:role/dev-cerbos-sa-role
AWS_WEB_IDENTITY_TOKEN_FILE: /var/run/secrets/eks.amazonaws.com/serviceaccount/token
Mounts:
/config from config-volume (ro)
/var/run/secrets/eks.amazonaws.com/serviceaccount from aws-iam-token (ro)
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-qkzmp (ro)
/work from work (rw)
Conditions:
Type Status
PodReadyToStartContainers True
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
aws-iam-token:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 86400
config-volume:
Type: ConfigMap (a volume populated by a ConfigMap)
Name: cerbos-config
Optional: false
work:
Type: EmptyDir (a temporary directory that shares a pod's lifetime)
Medium:
SizeLimit: <unset>
kube-api-access-qkzmp:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional: <nil>
DownwardAPI: true
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: <http://node.kubernetes.io/not-ready:NoExecute|node.kubernetes.io/not-ready:NoExecute> op=Exists for 300s
<http://node.kubernetes.io/unreachable:NoExecute|node.kubernetes.io/unreachable:NoExecute> op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 16m default-scheduler Successfully assigned dev-cerbos-namespace-test/cerbos-7bdbd89ddd-rw7n4 to ip-10-0-24-229.ap-south-1.compute.internal
Normal Pulled 16m kubelet Container image "<http://ghcr.io/cerbos/cerbos:0.38.1|ghcr.io/cerbos/cerbos:0.38.1>" already present on machine
Normal Created 16m kubelet Created container cerbos
Normal Started 16m kubelet Started container cerbos
Charith (Cerbos)
Port: <none>
Host Port: <none>
Charith (Cerbos)
Charith (Cerbos)
k get deploy cerbos -o yaml -n dev-cerbos-namespace-test
?prathmesh 1
08/20/2024, 11:07 AMk get deploy cerbos -o yaml -n dev-cerbos-namespace-test
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
<http://deployment.kubernetes.io/revision|deployment.kubernetes.io/revision>: "4"
<http://kubectl.kubernetes.io/last-applied-configuration|kubectl.kubernetes.io/last-applied-configuration>: |
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"labels":{"<http://app.kubernetes.io/instance|app.kubernetes.io/instance>":"cerbos","<http://app.kubernetes.io/name|app.kubernetes.io/name>":"cerbos","company":"cars24"},"name":"cerbos","namespace":"dev-cerbos-namespace-test"},"spec":{"replicas":1,"selector":{"matchLabels":{"<http://app.kubernetes.io/instance|app.kubernetes.io/instance>":"cerbos","<http://app.kubernetes.io/name|app.kubernetes.io/name>":"cerbos"}},"template":{"metadata":{"labels":{"<http://app.kubernetes.io/instance|app.kubernetes.io/instance>":"cerbos","<http://app.kubernetes.io/name|app.kubernetes.io/name>":"cerbos"}},"spec":{"containers":[{"args":["server","--config=/config/config.yaml","--log-level=INFO"],"env":[{"name":"ENVIRONMENT","value":"dev"},{"name":"PGHOST","value":"10.0.6.116"},{"name":"CERBOS_CONFIG","value":"/config/config.yaml"},{"name":"CERBOS_PASSWORD_HASH","valueFrom":{"secretKeyRef":{"key":"passwordHash","name":"cerbos-secret"}}},{"name":"CERBOS_USERNAME","valueFrom":{"secretKeyRef":{"key":"username","name":"cerbos-secret"}}},{"name":"POSTGRES_USERNAME","valueFrom":{"secretKeyRef":{"key":"postgresUser","name":"cerbos-secret"}}},{"name":"POSTGRES_PASSWORD","valueFrom":{"secretKeyRef":{"key":"postgresPassword","name":"cerbos-secret"}}}],"image":"<http://ghcr.io/cerbos/cerbos:0.38.1|ghcr.io/cerbos/cerbos:0.38.1>","imagePullPolicy":"IfNotPresent","name":"cerbos","volumeMounts":[{"mountPath":"/config","name":"config-volume","readOnly":true},{"mountPath":"/work","name":"work"}]}],"securityContext":{},"serviceAccountName":"dev-cerbos-sa","volumes":[{"configMap":{"name":"cerbos-config"},"name":"config-volume"},{"emptyDir":{},"name":"work"}]}}}}
creationTimestamp: "2024-08-20T09:55:48Z"
generation: 4
labels:
<http://app.kubernetes.io/instance|app.kubernetes.io/instance>: cerbos
<http://app.kubernetes.io/name|app.kubernetes.io/name>: cerbos
company: cars24
name: cerbos
namespace: dev-cerbos-namespace-test
resourceVersion: "36391550"
uid: 49009cc9-86b5-41b7-8238-b353bdfb4394
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
<http://app.kubernetes.io/instance|app.kubernetes.io/instance>: cerbos
<http://app.kubernetes.io/name|app.kubernetes.io/name>: cerbos
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
<http://app.kubernetes.io/instance|app.kubernetes.io/instance>: cerbos
<http://app.kubernetes.io/name|app.kubernetes.io/name>: cerbos
spec:
containers:
- args:
- server
- --config=/config/config.yaml
- --log-level=INFO
env:
- name: ENVIRONMENT
value: dev
- name: PGHOST
value: 10.0.6.116
- name: CERBOS_CONFIG
value: /config/config.yaml
- name: CERBOS_PASSWORD_HASH
valueFrom:
secretKeyRef:
key: passwordHash
name: cerbos-secret
- name: CERBOS_USERNAME
valueFrom:
secretKeyRef:
key: username
name: cerbos-secret
- name: POSTGRES_USERNAME
valueFrom:
secretKeyRef:
key: postgresUser
name: cerbos-secret
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
key: postgresPassword
name: cerbos-secret
image: <http://ghcr.io/cerbos/cerbos:0.38.1|ghcr.io/cerbos/cerbos:0.38.1>
imagePullPolicy: IfNotPresent
name: cerbos
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /config
name: config-volume
readOnly: true
- mountPath: /work
name: work
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: dev-cerbos-sa
serviceAccountName: dev-cerbos-sa
terminationGracePeriodSeconds: 30
volumes:
- configMap:
defaultMode: 420
name: cerbos-config
name: config-volume
- emptyDir: {}
name: work
status:
availableReplicas: 1
conditions:
- lastTransitionTime: "2024-08-20T10:26:14Z"
lastUpdateTime: "2024-08-20T10:26:14Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: "True"
type: Available
- lastTransitionTime: "2024-08-20T10:26:11Z"
lastUpdateTime: "2024-08-20T10:26:14Z"
message: ReplicaSet "cerbos-7bdbd89ddd" has successfully progressed.
reason: NewReplicaSetAvailable
status: "True"
type: Progressing
observedGeneration: 4
readyReplicas: 1
replicas: 1
updatedReplicas: 1
Charith (Cerbos)
prathmesh 1
08/20/2024, 11:10 AMnishant gupta
08/20/2024, 11:22 AMnishant gupta
08/20/2024, 11:22 AMnishant gupta
08/20/2024, 11:23 AMnishant gupta
08/20/2024, 11:23 AMTristan Colgate-McFarlane
08/20/2024, 11:25 AMCharith (Cerbos)
server.httpListenAddr
in Cerbos configuration file to [::]:3592
to see if that helps. k edit cm cerbos
and k rollout restart deploy/cerbos
.Tristan Colgate-McFarlane
08/20/2024, 11:36 AM[::]:3592]
I canprathmesh 1
08/20/2024, 12:14 PMserver.httpListenAddr
in config.yaml (ConfigMap) -
apiVersion: v1
kind: ConfigMap
metadata:
name: cerbos-config
namespace: dev-cerbos-namespace-test
data:
config.yaml: |
storage:
driver: "postgres"
postgres:
url: "postgres://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@dev-db-host:5432/postgres?sslmode=allow&search_path=cerbos"
server:
adminAPI:
enabled: true
adminCredentials:
username: ${CERBOS_USERNAME}
passwordHash: ${CERBOS_PASSWORD_HASH}
httpListenAddr: "[::]:3592"
but after rollout restart new pod is restarting again and again with logs -
k logs -f cerbos-59494bc6f9-wvnpr -n dev-cerbos-namespace-test
{"log.level":"info","@timestamp":"2024-08-20T12:09:14.700Z","log.logger":"cerbos.server","message":"maxprocs: Leaving GOMAXPROCS=8: CPU quota undefined"}
{"log.level":"info","@timestamp":"2024-08-20T12:09:14.700Z","log.logger":"cerbos.server","message":"Loading configuration from /config/config.yaml"}
{"log.level":"warn","@timestamp":"2024-08-20T12:09:14.700Z","log.logger":"cerbos.otel","message":"Disabling OTLP traces because neither OTEL_EXPORTER_OTLP_ENDPOINT nor OTEL_EXPORTER_OTLP_TRACES_ENDPOINT is defined"}
{"log.level":"info","@timestamp":"2024-08-20T12:09:14.700Z","log.logger":"cerbos.postgres","message":"Initializing Postgres storage","host":"dev-cars24-cf-common-db.chuskyscy5za.ap-south-1.rds.amazonaws.com","database":"postgres"}
{"log.level":"info","@timestamp":"2024-08-20T12:09:15.787Z","log.logger":"cerbos.db","message":"Checking database schema. Set skipSchemaCheck to true to disable."}
{"log.level":"info","@timestamp":"2024-08-20T12:09:15.794Z","log.logger":"cerbos.db","message":"Database schema check completed"}
{"log.level":"info","@timestamp":"2024-08-20T12:09:15.794Z","log.logger":"cerbos.telemetry","message":"Anonymous telemetry enabled. Disable via the config file or by setting the CERBOS_NO_TELEMETRY=1 environment variable"}
{"log.level":"info","@timestamp":"2024-08-20T12:09:15.795Z","log.logger":"cerbos.grpc","message":"Starting admin service"}
{"log.level":"info","@timestamp":"2024-08-20T12:09:15.795Z","log.logger":"cerbos.grpc","message":"Starting gRPC server at :3593"}
{"log.level":"info","@timestamp":"2024-08-20T12:09:15.796Z","log.logger":"cerbos.http","message":"Starting HTTP server at :3592"}
{"log.level":"info","@timestamp":"2024-08-20T12:10:12.445Z","log.logger":"cerbos.server","message":"Shutting down"}
{"log.level":"info","@timestamp":"2024-08-20T12:10:12.446Z","log.logger":"cerbos.http","message":"HTTP server stopped"}
{"log.level":"info","@timestamp":"2024-08-20T12:10:12.446Z","log.logger":"cerbos.grpc","message":"gRPC server stopped"}
{"log.level":"info","@timestamp":"2024-08-20T12:10:12.446Z","log.logger":"cerbos.server","message":"Shutdown complete"}
{"log.level":"info","@timestamp":"2024-08-20T12:10:12.855Z","log.logger":"cerbos.server","message":"maxprocs: No GOMAXPROCS change to reset"}
Tristan Colgate-McFarlane
08/20/2024, 12:27 PMprathmesh 1
08/20/2024, 12:29 PMWarning Unhealthy 18m (x6 over 19m) kubelet Liveness probe failed: Get "http://[2406:da1a:66e:5915:23b0::d]:3592/_cerbos/health": dial tcp [2406:da1a:66e:5915:23b0::d]:3592: connect: connection refused
Warning Unhealthy 14m (x31 over 19m) kubelet Readiness probe failed: Get "http://[2406:da1a:66e:5915:23b0::d]:3592/_cerbos/health": dial tcp [2406:da1a:66e:5915:23b0::d]:3592: connect: connection refused
Warning BackOff 12s (x52 over 14m) kubelet Back-off restarting failed container cerbos in pod cerbos-59494bc6f9-wvnpr_dev-cerbos-namespace-test(fb34ac55-0194-42b8-baac-e7175f
Charith (Cerbos)
:3592
"Starting HTTP server at :3592"
Tristan Colgate-McFarlane
08/20/2024, 1:00 PM[::]:3592
does seem to service both ipv6 ipv4 , where 0.0.0.0 or plain :3592
will only do v4, so as long as the config is being read correctly, it /should/ be OKnishant gupta
08/20/2024, 1:54 PMnishant gupta
08/20/2024, 1:54 PM