The Stateful Cluster Operator is a custom Kubernetes controller that implements the v1.StatefulSet interface, but implements slightly different logic when it comes to replicating your pods.
Note: Never blindly deploy hosted manifests to your cluster. Always review all manifests before deploying!
# Create stateful-cluster-operator namespace
kubectl create namespace stateful-cluster-operator
# Create ServiceAccount, Role, and RoleBinding
kubectl apply --namespace stateful-cluster-operator -f https://github.com/adamgoose/stateful-cluster-operator/blob/master/deploy/service_account.yaml
kubectl apply --namespace stateful-cluster-operator -f https://github.com/adamgoose/stateful-cluster-operator/blob/master/deploy/role.yaml
kubectl apply --namespace stateful-cluster-operator -f https://github.com/adamgoose/stateful-cluster-operator/blob/master/deploy/role_binding.yaml
# Deploy the Operator
kubectl apply --namespace stateful-cluster-operator -f https://github.com/adamgoose/stateful-cluster-operator/blob/master/deploy/operator.yaml
Kubernetes offers a StatefulSet. Its design incorporates sequentiality.
From the K8s documentation:
This has nice properties as long as there are no nodes or pods that fail. However, failure can create a hole in our sequence:
In the StatefulSet design, Pod 1 should eventually recover. However, this is not always possible. For example, if the node is bad, the pod should be re-scheduled to a new node. However, if the pod has a claim to a PersistentVolume on the bad node, it cannot be re-scheduled. If we delete the pod in a bad state, the StatefulSet will create a new pod with the same identity. However, re-using an identity for a pod that no longer has the state of the failed pod is problemtatic. Reference: https://kubernetes.io/docs/tasks/run-application/force-delete-stateful-set-pod/
StatefulClusters are Kubernetes Custom Resource Definitions that implement the v1.StatefulSetSpec and v1.StatefulSetCluster types.
apiVersion: enge.me/v1alpha1
kind: StatefulCluster
metadata:
annotations:
name: coder
spec:
replicas: 1
selector:
matchLabels:
app: coder
enge.me/statefulcluster: coder
template:
spec:
containers:
- args:
- --allow-http
- --no-auth
- --host
- 0.0.0.0
image: codercom/code-server
name: coder-stateful
ports:
- containerPort: 8443
name: https
volumeMounts:
- mountPath: /home/coder/project
name: data
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
Content type
Image
Digest
Size
48.1 MB
Last updated
over 7 years ago
docker pull adamgoose/stateful-cluster-operator