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

k8s: add RBAC and flesh out example #526

Merged
merged 1 commit into from
Apr 12, 2022
Merged
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
88 changes: 0 additions & 88 deletions k8s/basic.yaml

This file was deleted.

182 changes: 182 additions & 0 deletions k8s/example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# This file contains an example configuration of SpiceDB in Kubernetes.
#
# It creates the following:
# - A single node deployment with no persistence (in-memory datastore)
# - Ports for the gRPC and HTTP APIs
# - Ports for internal dispatching and metrics
# - TLS is NOT securing any connections
# - Logging configured at the debug log-level
#
# To apply this configuration execute the following:
# kubectl -n $YOUR_NAMESPACE create secret generic spicedb --from-literal=SPICEDB_GRPC_PRESHARED_KEY=$YOUR_SECRET
# kubectl -n $YOUR_NAMESPACE create -f example.yaml
---
apiVersion: "v1"
kind: "Service"
metadata:
name: "spicedb"
labels:
app.kubernetes.io/name: "spicedb"
app.kubernetes.io/version: "example"
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9090"
spec:
selector:
app: "spicedb"
type: "ClusterIP"
ports:
- name: "grpc"
port: 50051
protocol: "TCP"
targetPort: 50051
- name: "http"
port: 8443
protocol: "TCP"
targetPort: 8443
- name: "dispatch"
port: 50053
protocol: "TCP"
targetPort: 50053
- name: "prometheus"
port: 9090
protocol: "TCP"
targetPort: 9090
---
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
name: "spicedb"
labels:
app.kubernetes.io/name: "spicedb"
app.kubernetes.io/version: "example"
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: "spicedb"
app.kubernetes.io/version: "example"
strategy:
type: "RollingUpdate"
rollingUpdate:
maxSurge: "25%"
maxUnavailable: "25%"
progressDeadlineSeconds: 600
template:
metadata:
labels:
app.kubernetes.io/name: "spicedb"
app.kubernetes.io/version: "example"
spec:
dnsPolicy: "ClusterFirst"
restartPolicy: "Always"
terminationGracePeriodSeconds: 30
serviceAccountName: "spicedb"
containers:
- name: "spicedb"
image: "quay.io/authzed/spicedb:latest"
imagePullPolicy: "Always"
command: ["spicedb", "serve"]
env:
# These flags are used to enable TLS for the gRPC and HTTP ports:
#
# - name: "SPICEDB_GRPC_TLS_KEY_PATH"
# valueFrom:
# secretKeyRef:
# name: "spicedb"
# key: "SPICEDB_GRPC_KEY_PATH"
# - name: "SPICEDB_GRPC_TLS_CERT_PATH"
# valueFrom:
# secretKeyRef:
# name: "spicedb"
# key: "SPICEDB_GRPC_CERT_PATH"
# - name: "SPICEDB_HTTP_TLS_KEY_PATH"
# valueFrom:
# secretKeyRef:
# name: "spicedb"
# key: "SPICEDB_HTTP_KEY_PATH"
# - name: "SPICEDB_GRPC_HTTP_CERT_PATH"
# valueFrom:
# secretKeyRef:
# name: "spicedb"
# key: "SPICEDB_HTTP_CERT_PATH"
#
# These flags are used to enable a persistent datastore along
# with cluster dispatching. For more info see:
# https://docs.authzed.com/spicedb/selecting-a-datastore
#
# - name: "SPICEDB_DATASTORE_ENGINE"
# value: "cockroachdb"
# - name: "SPICEDB_DATASTORE_CONN_URI"
# valueFrom:
# secretKeyRef:
# name: "spicedb"
# key: "SPICEDB_DATASTORE_CONN_URI"
# - name: "SPICEDB_DISPATCH_UPSTREAM_ADDR"
# value: "kubernetes:///spicedb:dispatch"
- name: "SPICEDB_LOG_LEVEL"
value: "debug"
- name: "SPICEDB_HTTP_ENABLED"
value: "true"
- name: "SPICEDB_GRPC_SHUTDOWN_GRACE_PERIOD"
value: "1s"
- name: "SPICEDB_GRPC_PRESHARED_KEY"
valueFrom:
secretKeyRef:
name: "spicedb"
key: "SPICEDB_GRPC_PRESHARED_KEY"
ports:
- name: "grpc"
containerPort: 50051
protocol: "TCP"
- name: "http"
containerPort: 8443
protocol: "TCP"
- name: "dispatch"
containerPort: 50053
protocol: "TCP"
- name: "prometheus"
containerPort: 9090
protocol: "TCP"
readinessProbe:
exec:
command: ["grpc_health_probe", "-v", "-addr=localhost:50051"]
failureThreshold: 5
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
---
apiVersion: "v1"
kind: "ServiceAccount"
metadata:
name: "spicedb"
labels:
app.kubernetes.io/name: "spicedb"
app.kubernetes.io/version: "example"
---
apiVersion: "rbac.authorization.k8s.io/v1"
kind: "Role"
metadata:
name: "watch-service"
labels:
app.kubernetes.io/name: "spicedb"
app.kubernetes.io/version: "example"
rules:
- apiGroups: [""]
resources: ["endpoints"]
verbs: ["get", "watch"]
Copy link
Contributor

Choose a reason for hiding this comment

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

you should need list too?

Copy link
Member Author

Choose a reason for hiding this comment

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

not according to the kuberesolver readme

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, super weird that it directly queries instead of using a client-go informer (which would've used list+watch)

---
apiVersion: "rbac.authorization.k8s.io/v1"
kind: "RoleBinding"
metadata:
name: "spicedb-watch-service"
labels:
app.kubernetes.io/name: "spicedb"
app.kubernetes.io/version: "example"
subjects:
- kind: "ServiceAccount"
name: "spicedb"
roleRef:
apiGroup: "rbac.authorization.k8s.io"
kind: "Role"
name: "watch-service"