1
votes

I have kubernetes installed on bare metal ubuntu server, below is the output of kubectl version command

Client Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.0", GitCommit:"fff5156092b56e6bd60fff75aad4dc9de6b6ef37", GitTreeState:"clean", BuildDate:"2017-03-28T16:36:33Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.3", GitCommit:"0480917b552be33e2dba47386e51decb1a211df6", GitTreeState:"clean", BuildDate:"2017-05-10T15:38:08Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}

I am running google shellinabox inside a docker container. It all works well with the docker container, but when I put the same image inside a kubernetes pod and expose it with a kubernetes service, my browser session to shellinabox times out after ~60 secs. Since this works fine with standalone docker container, I think this is caused by kubernetes. Is there any timeout on the kubernetes and how do I configure that.

Any help?

1
i tried sspreitzer/shellinabox:latest this image in Kubernetes v1.7.1. I didn't see the time out issue. which image your using?sfgroups
@sfgroups I created my own image on alpinePMat
@sfgroups this problem only exists if replicas is more than 1PMat
ahh, by default service will do the round-rabin load balance the traffic. can you set server session Affinity to clientIP and test? service.spec.sessionAffinity: ClientIPsfgroups
@sfgroups awesome, it seems to work. Please, update your answer belowPMat

1 Answers

2
votes

Enable the session Affinity to direct the traffic to one pod per client session here is the samepl deployment.

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: shellinabox
  labels:
    k8s-app: shellinabox
    tier: frontend
  namespace: default
spec:
  replicas: 2
  template:
    metadata:
      labels:
        k8s-app: shellinabox
    spec:      
      containers:
      - name: shellinabox        
        image: sspreitzer/shellinabox:latest
        env:
        - name: SIAB_PASSWORD
          value: abc123
        - name: SIAB_SUDO
          value: 'true'        
        ports:
        - containerPort: 4200
---
apiVersion: v1
kind: Service
metadata:
  name: shellinabox-svc
  labels:
    app: shellinabox-svc
  namespace: default
spec:
  type: NodePort
  ports:
    - port: 4200
      targetPort: 4200     
  selector:
    k8s-app: shellinabox
  sessionAffinity: ClientIP