Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pause a kubernetes service

I've got a setup described bellow - so a simple replication controller, service and an https ingress deployed with kubernetes on google cloud.

I need to kill my app for a bit so that I can test how the rest of my stack reacts - what's a good way to do it?

I've tried deleting the service, but when I've recreated it, it wouldn't pick up the backend service (replication controller and pod got created and I could access them internally, but not via the ingress - the service didn't see it.

echo "
apiVersion: v1
kind: Service
metadata:
  name: nodeapp-https
  labels:
    app: nodeapp-https
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 8080
    protocol: TCP
    name: http
  selector:
    app: nodeapp-https
---
apiVersion: v1
kind: ReplicationController
metadata:
  name: nodeapp-https
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: nodeapp-https
    spec:
      containers:
      - name: nodeapp-https
        image: gcr.io/my-project/node-app:v84
        ports:
        - containerPort: 8080
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nodeapp-httpss
spec:
  tls:
  - secretName: node-app-secret
  backend:
    serviceName: nodeapp-https
    servicePort: 80
" | kubectl create -f -
like image 764
Zlatko Avatar asked Jan 09 '17 10:01

Zlatko


1 Answers

You could set the replica count to 0 for the duration of the test. When you're finished testing, you would reset the replica count to the desired number to bring your app back up.

The command to do this would be

$ kubectl scale rc nodeapp-https --replicas=0
... do your test
$ kubectl scale rc nodeapp-https --replicas=1
like image 102
Pixel Elephant Avatar answered Sep 27 '22 19:09

Pixel Elephant