Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Create a yaml file to define our test ubuntu deployment. In this example we have sshd echoing to stdout (-e argument) in order to see the logs in Kubernetes.


Code Block
$ vi ubuntu.yaml

...

Code Block
languageyml
titleubuntu.yaml
apiVersion: v1
kind: Service
metadata:
  name: ubuntu
  labels:
    app: ubuntu
spec:
  type: NodePort
  ports:
    - port: 22
      targetPort: 22
      nodePort: 30022
  selector:
    app: ubuntu
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ubuntu
  labels:
    app: ubuntu
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ubuntu
  template:
    metadata:
      labels:
        app: ubuntu
    spec:
      containers:
        - name: ubuntu
          image: rastasheep/ubuntu-sshd:18.04
          command: [ "/usr/sbin/sshd","-D","-e" ]


Deploy it

Code Block
kubectl apply -f ubuntu.yaml

...

Code Block
ssh -p 30022 root@localhost


Check Logging

Code Block
$ kubectl get pods                      
NAME                     READY   STATUS    RESTARTS   AGE
ubuntu-ddc759bb8-5blsd   1/1     Running   0          2m14s

$ kubectl logs -f ubuntu-ddc759bb8-5blsd
Accepted password for root from 192.168.65.6 port 57022 ssh2
Received disconnect from 192.168.65.6 port 57022:11: disconnected by user
Disconnected from user root 192.168.65.6 port 57022
Failed password for root from 192.168.65.6 port 57088 ssh2
Failed password for root from 192.168.65.6 port 57088 ssh2
Failed password for root from 192.168.65.6 port 57088 ssh2








References

...