Kubernetes - Stateful Sets đ
Description đ
Stateful sets are used to manage stateful applications. They are similar to deployments but they provide guarantees about the ordering and uniqueness of the pods they create. Stateful sets are useful for applications that require one or more of the following. Stable, unique network identifiers. Stable, persistent storage. Ordered, graceful deployment and scaling. Ordered, automated rolling updates.
Basic Commands đ
-
scale a
stateful setkubectl scale statefulset <stateful-set-name> --replicas=<number-of-replicas>
Examples đ§Š
-
stateful setdefinitionapiVersion: apps/v1 kind: StatefulSet metadata: name: mysql labels: app: mysql spec: replicas: 3 selector: matchLabels: app: mysql serviceName: mysql-h # causes the pods to be created in parallel, rather than sequentially. will maintain all of its other properties. podManagementPolicy: Parallel template: metadata: labels: app: mysql spec: containers: - name: mysql image: mysql