mirror of
https://github.com/acedemand/kubernetes-essentials.git
synced 2021-08-24 18:29:57 +03:00
what can go wrong
This commit is contained in:
26
08-storage/portability/storageclass/change-sc/Readme.md
Normal file
26
08-storage/portability/storageclass/change-sc/Readme.md
Normal file
@@ -0,0 +1,26 @@
|
||||
### wcgw
|
||||
```bash
|
||||
kubectl create ns redis
|
||||
kubectl apply -f redis-master.yaml
|
||||
kubectl get pods -n redis
|
||||
kubectl get pvc -n redis
|
||||
kubectl get pv
|
||||
kubectl exec -it redis-master-0 -- /bin/sh
|
||||
redis-cli
|
||||
set name pamir
|
||||
127.0.0.1:6379> get name
|
||||
"pamir"
|
||||
exit
|
||||
exit
|
||||
kubectl delete -f redis-master.yaml
|
||||
kubectl apply -f redis-master-ssd-transition.yaml
|
||||
kubectl exec -it redis-master-0 -n redis -- /bin/sh
|
||||
# redis-cli
|
||||
127.0.0.1:6379> get name
|
||||
"pamir"
|
||||
127.0.0.1:6379> exit
|
||||
# exit
|
||||
kubectl delete -f redis-master-ssd-transition.yaml
|
||||
kubectl apply -f redis-ssd-after-transition.yaml
|
||||
|
||||
```
|
||||
@@ -0,0 +1,163 @@
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
labels:
|
||||
app: redis-master
|
||||
name: redis-master
|
||||
namespace: redis
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 3
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: redis-master
|
||||
serviceName: redis-master
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
app: redis-master
|
||||
spec:
|
||||
affinity:
|
||||
podAntiAffinity:
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- podAffinityTerm:
|
||||
labelSelector:
|
||||
matchExpressions:
|
||||
- key: app
|
||||
operator: In
|
||||
values:
|
||||
- redis-master
|
||||
topologyKey: kubernetes.io/hostname
|
||||
weight: 100
|
||||
containers:
|
||||
- args:
|
||||
- /opt/redis.conf
|
||||
command:
|
||||
- /opt/bin/k8s-redis-ha-server
|
||||
env:
|
||||
- name: SERVICE
|
||||
value: redis-master
|
||||
- name: SERVICE_PORT
|
||||
value: redis-master
|
||||
- name: SENTINEL
|
||||
value: redis-sentinel
|
||||
- name: SENTINEL_PORT
|
||||
value: redis-sentinel
|
||||
image: redis:4.0.11
|
||||
imagePullPolicy: IfNotPresent
|
||||
name: redis-master
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
name: redis-master
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- redis-cli
|
||||
- info
|
||||
- server
|
||||
failureThreshold: 3
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 1
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- redis-cli
|
||||
- info
|
||||
- server
|
||||
failureThreshold: 3
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 1
|
||||
resources:
|
||||
limits:
|
||||
cpu: "1"
|
||||
memory: 512Mi
|
||||
requests:
|
||||
cpu: "1"
|
||||
memory: 512Mi
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
volumeMounts:
|
||||
- mountPath: /data
|
||||
name: redis-master-data
|
||||
- mountPath: /opt
|
||||
name: opt
|
||||
dnsPolicy: ClusterFirst
|
||||
initContainers:
|
||||
- command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- sysctl -w net.core.somaxconn=10000
|
||||
image: busybox
|
||||
imagePullPolicy: Always
|
||||
name: init-sysctl
|
||||
resources: {}
|
||||
securityContext:
|
||||
privileged: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
|
||||
- image: rifatx/redis-replication:master-latest
|
||||
imagePullPolicy: Always
|
||||
name: redis-ha-master
|
||||
resources: {}
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
volumeMounts:
|
||||
- mountPath: /opt
|
||||
name: opt
|
||||
|
||||
|
||||
- command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- cp -rf /data/* /data2/
|
||||
image: busybox
|
||||
imagePullPolicy: Always
|
||||
name: db-copy
|
||||
resources: {}
|
||||
securityContext:
|
||||
privileged: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
imagePullPolicy: Always
|
||||
volumeMounts:
|
||||
- mountPath: /data
|
||||
name: redis-master-volume
|
||||
- mountPath: /data2
|
||||
name: redis-master-data
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
|
||||
volumes:
|
||||
- emptyDir: {}
|
||||
name: opt
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
annotations:
|
||||
volume.beta.kubernetes.io/storage-class: standard
|
||||
name: redis-master-volume
|
||||
spec:
|
||||
storageClassName: standard
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
- metadata:
|
||||
annotations:
|
||||
volume.beta.kubernetes.io/storage-class: ssd
|
||||
name: redis-master-data
|
||||
spec:
|
||||
storageClassName: ssd
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
122
08-storage/portability/storageclass/change-sc/redis-master.yaml
Normal file
122
08-storage/portability/storageclass/change-sc/redis-master.yaml
Normal file
@@ -0,0 +1,122 @@
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
labels:
|
||||
app: redis-master
|
||||
name: redis-master
|
||||
namespace: redis
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 3
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: redis-master
|
||||
serviceName: redis-master
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
app: redis-master
|
||||
spec:
|
||||
containers:
|
||||
- args:
|
||||
- /opt/redis.conf
|
||||
command:
|
||||
- /opt/bin/k8s-redis-ha-server
|
||||
env:
|
||||
- name: SERVICE
|
||||
value: redis-master
|
||||
- name: SERVICE_PORT
|
||||
value: redis-master
|
||||
- name: SENTINEL
|
||||
value: redis-sentinel
|
||||
- name: SENTINEL_PORT
|
||||
value: redis-sentinel
|
||||
image: redis:4.0.11
|
||||
imagePullPolicy: IfNotPresent
|
||||
name: redis-master
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
name: redis-master
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- redis-cli
|
||||
- info
|
||||
- server
|
||||
failureThreshold: 3
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 1
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- redis-cli
|
||||
- info
|
||||
- server
|
||||
failureThreshold: 3
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 1
|
||||
resources:
|
||||
limits:
|
||||
cpu: "1"
|
||||
memory: 512Mi
|
||||
requests:
|
||||
cpu: "1"
|
||||
memory: 512Mi
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
volumeMounts:
|
||||
- mountPath: /data
|
||||
name: redis-master-volume
|
||||
- mountPath: /opt
|
||||
name: opt
|
||||
dnsPolicy: ClusterFirst
|
||||
initContainers:
|
||||
- command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- sysctl -w net.core.somaxconn=10000
|
||||
image: busybox
|
||||
imagePullPolicy: Always
|
||||
name: init-sysctl
|
||||
resources: {}
|
||||
securityContext:
|
||||
privileged: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
|
||||
- image: rifatx/redis-replication:master-latest
|
||||
imagePullPolicy: Always
|
||||
name: redis-ha-master
|
||||
resources: {}
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
volumeMounts:
|
||||
- mountPath: /opt
|
||||
name: opt
|
||||
|
||||
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
|
||||
volumes:
|
||||
- emptyDir: {}
|
||||
name: opt
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
annotations:
|
||||
volume.beta.kubernetes.io/storage-class: standard
|
||||
name: redis-master-volume
|
||||
spec:
|
||||
storageClassName: standard
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
@@ -0,0 +1,132 @@
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
labels:
|
||||
app: redis-master
|
||||
name: redis-master
|
||||
namespace: redis
|
||||
spec:
|
||||
podManagementPolicy: OrderedReady
|
||||
replicas: 3
|
||||
revisionHistoryLimit: 10
|
||||
selector:
|
||||
matchLabels:
|
||||
app: redis-master
|
||||
serviceName: redis-master
|
||||
template:
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
app: redis-master
|
||||
spec:
|
||||
affinity:
|
||||
podAntiAffinity:
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- podAffinityTerm:
|
||||
labelSelector:
|
||||
matchExpressions:
|
||||
- key: app
|
||||
operator: In
|
||||
values:
|
||||
- redis-master
|
||||
topologyKey: kubernetes.io/hostname
|
||||
weight: 100
|
||||
containers:
|
||||
- args:
|
||||
- /opt/redis.conf
|
||||
command:
|
||||
- /opt/bin/k8s-redis-ha-server
|
||||
env:
|
||||
- name: SERVICE
|
||||
value: redis-master
|
||||
- name: SERVICE_PORT
|
||||
value: redis-master
|
||||
- name: SENTINEL
|
||||
value: redis-sentinel
|
||||
- name: SENTINEL_PORT
|
||||
value: redis-sentinel
|
||||
image: redis:4.0.11
|
||||
imagePullPolicy: IfNotPresent
|
||||
name: redis-master
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
name: redis-master
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- redis-cli
|
||||
- info
|
||||
- server
|
||||
failureThreshold: 3
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 1
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- redis-cli
|
||||
- info
|
||||
- server
|
||||
failureThreshold: 3
|
||||
periodSeconds: 10
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 1
|
||||
resources:
|
||||
limits:
|
||||
cpu: "1"
|
||||
memory: 512Mi
|
||||
requests:
|
||||
cpu: "1"
|
||||
memory: 512Mi
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
volumeMounts:
|
||||
- mountPath: /data
|
||||
name: redis-master-data
|
||||
- mountPath: /opt
|
||||
name: opt
|
||||
dnsPolicy: ClusterFirst
|
||||
initContainers:
|
||||
- command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- sysctl -w net.core.somaxconn=10000
|
||||
image: busybox
|
||||
imagePullPolicy: Always
|
||||
name: init-sysctl
|
||||
resources: {}
|
||||
securityContext:
|
||||
privileged: true
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
|
||||
- image: rifatx/redis-replication:master-latest
|
||||
imagePullPolicy: Always
|
||||
name: redis-ha-master
|
||||
resources: {}
|
||||
terminationMessagePath: /dev/termination-log
|
||||
terminationMessagePolicy: File
|
||||
volumeMounts:
|
||||
- mountPath: /opt
|
||||
name: opt
|
||||
restartPolicy: Always
|
||||
schedulerName: default-scheduler
|
||||
securityContext: {}
|
||||
terminationGracePeriodSeconds: 30
|
||||
|
||||
volumes:
|
||||
- emptyDir: {}
|
||||
name: opt
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
annotations:
|
||||
volume.beta.kubernetes.io/storage-class: ssd
|
||||
name: redis-master-data
|
||||
spec:
|
||||
storageClassName: ssd
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
Reference in New Issue
Block a user