kubernetes replicasets

This commit is contained in:
G.J.C. Strikwerda 2018-11-01 10:41:57 +01:00
parent 50e23a9233
commit bc15b0969a
1 changed files with 93 additions and 0 deletions

93
kubernetes.replicasets Normal file
View File

@ -0,0 +1,93 @@
kubernetes replica sets:
aanmaken manifest met replicas: 1
[ger@master ~]$ cat kuard-rs.yaml
apiVersion: extensions/v1beta1
kind: ReplicaSet
metadata:
name: kuard
spec:
replicas: 1
template:
metadata:
labels:
app: kuard
version: "2"
spec:
containers:
- name: kuard
image: "gcr.io/kuar-demo/kuard-amd64:2"
[ger@master ~]$ kubectl apply -f ./kuard-rs.yaml
replicaset.extensions/kuard created
check:
[ger@master ~]$ kubectl get pods
NAME READY STATUS RESTARTS AGE
kuard-f25dt 1/1 Running 0 24s
meer info:
[ger@master ~]$ kubectl describe rs kuard
Name: kuard
Namespace: default
Selector: app=kuard,version=2
Labels: app=kuard
version=2
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"extensions/v1beta1","kind":"ReplicaSet","metadata":{"annotations":{},"name":"kuard","namespace":"default"},"spec":{"replica...
Replicas: 1 current / 1 desired
Pods Status: 1 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
Labels: app=kuard
version=2
Containers:
kuard:
Image: gcr.io/kuar-demo/kuard-amd64:2
Port: <none>
Host Port: <none>
Environment: <none>
Mounts: <none>
Volumes: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 40s replicaset-controller Created pod: kuard-f25dt
opschalen naar 4 replica's:
[ger@master ~]$ kubectl scale rs kuard --replicas=4 --all
replicaset.extensions/kuard scaled
[ger@master ~]$ kubectl get pods
NAME READY STATUS RESTARTS AGE
kuard-66877 0/1 ContainerCreating 0 9s
kuard-8trx2 0/1 ContainerCreating 0 9s
kuard-dlb2c 0/1 ContainerCreating 0 9s
kuard-f25dt 1/1 Running 0 4m59s
[ger@master ~]$ kubectl get pods
NAME READY STATUS RESTARTS AGE
kuard-66877 1/1 Running 0 30s
kuard-8trx2 1/1 Running 0 30s
kuard-dlb2c 1/1 Running 0 30s
kuard-f25dt 1/1 Running 0 5m20s
autoscale:
[ger@master ~]$ kubectl autoscale rs kuard --min=2 --max=5 --cpu-percent=80
horizontalpodautoscaler.autoscaling/kuard autoscaled
check hpa (horizontal pod autoscaler):
[ger@master ~]$ kubectl get hpa
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
kuard ReplicaSet/kuard <unknown>/80% 2 5 0 11s