Skip to content

Instantly share code, notes, and snippets.

@mavimo
Last active November 25, 2018 20:58
Show Gist options
  • Save mavimo/df46a89d6bbda604207aa75af36fb6a9 to your computer and use it in GitHub Desktop.
Save mavimo/df46a89d6bbda604207aa75af36fb6a9 to your computer and use it in GitHub Desktop.
apiVersion: v1
kind: Service
metadata:
labels:
app: cassandra
name: cassandra
spec:
clusterIP: None
ports:
- port: 9042
selector:
app: cassandra
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
name: cassandra
labels:
app: cassandra
spec:
serviceName: cassandra
replicas: 3
selector:
matchLabels:
app: cassandra
template:
metadata:
labels:
app: cassandra
spec:
containers:
- name: cassandra
image: gcr.io/google-samples/cassandra:v14
imagePullPolicy: Always
ports:
- containerPort: 7000
name: intra-node
- containerPort: 7001
name: tls-intra-node
- containerPort: 7199
name: jmx
- containerPort: 9042
name: cql
resources:
limits:
cpu: "500m"
memory: 1Gi
requests:
cpu: "500m"
memory: 1Gi
securityContext:
capabilities:
add:
- IPC_LOCK
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "PID=$(pidof java) && kill $PID && while ps -p $PID > /dev/null; do sleep 1; done"]
env:
- name: MAX_HEAP_SIZE
value: 512M
- name: HEAP_NEWSIZE
value: 100M
- name: CASSANDRA_SEEDS
value: "cassandra-0.cassandra.default.svc.cluster.local"
- name: CASSANDRA_CLUSTER_NAME
value: "K8Demo"
- name: CASSANDRA_DC
value: "DC1-K8Demo"
- name: CASSANDRA_RACK
value: "Rack1-K8Demo"
- name: CASSANDRA_AUTO_BOOTSTRAP
value: "false"
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
readinessProbe:
exec:
command:
- /bin/bash
- -c
- /ready-probe.sh
initialDelaySeconds: 15
timeoutSeconds: 5
volumeMounts:
- name: cassandra-data
mountPath: /cassandra_data
volumeClaimTemplates:
- metadata:
name: cassandra-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
storageClassName: hcloud-volumes
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
namespace: kube-system
name: hcloud-volumes
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: com.hetzner.csi-hcloud
---
kind: StatefulSet
apiVersion: apps/v1beta1
metadata:
namespace: kube-system
name: controller-csi-hcloud
spec:
serviceName: "csi-hcloud"
replicas: 1
template:
metadata:
labels:
app: controller-csi-hcloud
role: csi-hcloud
spec:
serviceAccount: sa-controller-csi-hcloud
containers:
- name: csi-provisioner
image: quay.io/k8scsi/csi-provisioner:v0.3.0
args:
- "--provisioner=com.hetzner.csi-hcloud"
- "--csi-address=$(CSI_SOCKET)"
- "--v=5"
env:
- name: CSI_SOCKET
value: /var/lib/csi/sockets/pluginproxy/csi.sock
imagePullPolicy: "Always"
volumeMounts:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
- name: csi-attacher
image: quay.io/k8scsi/csi-attacher:v0.3.0
args:
- "--csi-address=$(CSI_SOCKET)"
- "--v=5"
env:
- name: CSI_SOCKET
value: /var/lib/csi/sockets/pluginproxy/csi.sock
imagePullPolicy: "Always"
volumeMounts:
- mountPath: /var/lib/csi/sockets/pluginproxy/
name: socket-dir
- name: csi-hcloud
image: lkdevelopment/csi-hcloud:latest
args:
- "--endpoint=$(CSI_SOCKET)"
- "--token=$(HCLOUD_TOKEN)"
- "--url=$(HCLOUD_ENDPOINT)"
- "--hostname=$(HOSTNAME)"
env:
- name: CSI_SOCKET
value: unix:///var/lib/csi/sockets/pluginproxy/csi.sock
- name: HCLOUD_TOKEN
valueFrom:
secretKeyRef:
name: hcloud
key: token
- name: HCLOUD_ENDPOINT
value: https://api.hetzner.cloud/v1
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
imagePullPolicy: "Always"
volumeMounts:
- mountPath: /var/lib/csi/sockets/pluginproxy/
name: socket-dir
volumes:
- name: socket-dir
emptyDir: {}
---
kind: ServiceAccount
apiVersion: v1
metadata:
namespace: kube-system
name: sa-controller-csi-hcloud
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: kube-system
name: binding-csi-hcloud-provisioner
subjects:
- kind: ServiceAccount
namespace: kube-system
name: sa-controller-csi-hcloud
roleRef:
kind: ClusterRole
name: system:csi-external-provisioner
apiGroup: rbac.authorization.k8s.io
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: kube-system
name: binding-csi-hcloud-attacher
subjects:
- kind: ServiceAccount
namespace: kube-system
name: sa-controller-csi-hcloud
roleRef:
kind: ClusterRole
name: system:csi-external-attacher
apiGroup: rbac.authorization.k8s.io
---
## for the Node
kind: DaemonSet
apiVersion: apps/v1
metadata:
namespace: kube-system
name: node-csi-hcloud
spec:
selector:
matchLabels:
app: node-csi-hcloud
template:
metadata:
labels:
app: node-csi-hcloud
role: csi-hcloud
spec:
serviceAccount: sa-node-csi-hcloud
hostNetwork: true
containers:
- name: driver-registrar
image: quay.io/k8scsi/driver-registrar:v0.3.0
args:
- "--csi-address=$(CSI_SOCKET)"
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
- "--v=5"
env:
- name: CSI_SOCKET
value: /csi/csi.sock
- name: DRIVER_REG_SOCK_PATH
value: /var/lib/kubelet/plugins/com.hetzner.csi-hcloud/csi.sock
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
volumeMounts:
- mountPath: /csi/
name: plugin-mount
- name: registration-dir
mountPath: /registration/
- name: csi-hcloud
image: lkdevelopment/csi-hcloud:latest
args:
- "--endpoint=$(CSI_SOCKET)"
- "--token=$(HCLOUD_TOKEN)"
- "--url=$(HCLOUD_ENDPOINT)"
env:
- name: CSI_SOCKET
value: unix:///csi/csi.sock
- name: HCLOUD_TOKEN
valueFrom:
secretKeyRef:
name: hcloud
key: token
- name: HCLOUD_ENDPOINT
value: https://api.hetzner.cloud/v1
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
imagePullPolicy: "Always"
securityContext:
privileged: true
capabilities:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
volumeMounts:
- mountPath: /csi
name: plugin-mount
- mountPath: /var/lib/kubelet
mountPropagation: "Bidirectional"
name: pod-mount
- mountPath: /dev
name: device-mount
volumes:
- name: registration-dir
hostPath:
path: /var/lib/kubelet/plugins/
type: DirectoryOrCreate
- name: plugin-mount
hostPath:
path: /var/lib/kubelet/plugins/com.hetzner.csi-hcloud
type: DirectoryOrCreate
- name: pod-mount
hostPath:
path: /var/lib/kubelet
type: Directory
- name: device-mount
hostPath:
path: /dev
---
kind: ServiceAccount
apiVersion: v1
metadata:
namespace: kube-system
name: sa-node-csi-hcloud
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: kube-system
name: binding-csi-hcloud-registrar
subjects:
- kind: ServiceAccount
namespace: kube-system
name: sa-node-csi-hcloud
roleRef:
kind: ClusterRole
name: registrar-role-csi-hcloud
apiGroup: rbac.authorization.k8s.io
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: kube-system
name: registrar-role-csi-hcloud
rules:
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "update"]
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "watch", "create", "update", "patch"]
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "update","create"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment