Steps to create a pod with nginx container and get shell to it:
- Create config file shell-demo.yaml
apiVersion: v1 kind: Pod metadata: name: shell-demo spec: volumes: - name: shared-data emptyDir: {} containers: - name: nginx image: nginx volumeMounts: - name: shared-data mountPath: /usr/share/nginx/html hostNetwork: true dnsPolicy: Default
- Create the pod
kubectl apply -f shell-demo.yaml
- Get a shell to the running container (container name will be needed in case more than one containers in pod)
kubectl exec --stdin --tty shell-demo -- /bin/bash
- Create a root page for nginx (in shell window)
echo 'Hello shell demo' > /usr/share/nginx/html/index.html
- Install curl and test the site
apt-get update
apt-get install curl
curl http://localhost/
The output should show:Hello shell demo