pretty new to kubernetes/kops, I have followed the tutorial for kops on aws, and I have created a cluster. I'd like to run a very simple container from hub.docker on the cluster, how do I go about adding this container to the cluster? Is it in the cluster config file or will I need to add another image to the nodes.
For example to run the nginx web server in your cluster you can use the command line below, this will download image from docker hub and start the instance.
kubectl run nginx --image=nginx --port=80
Here is command https://kubernetes.io/docs/user-guide/kubectl/v1.8/.
To run your image change the nginx with your image name.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
run: nginx
name: nginx
spec:
replicas: 2
selector:
matchLabels:
run: nginx
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
labels:
run: nginx
tier: frontend
spec:
containers:
- image: nginx:1.10
imagePullPolicy: IfNotPresent
name: nginx
lifecycle:
preStop:
exec:
command: ["/usr/sbin/nginx","-s","quit"]
restartPolicy: Always
terminationGracePeriodSeconds: 30
store above file in nginx.yaml
file then run it with kubectl command.
kubectl create -f nginx.yaml
In Kubernetes, container could be run as Pod, which is a resource in Kubernetes.
You could prepare a yaml or json file to create your pod with command kubectl create -f $yourfile
Example could be found here https://github.com/kubernetes/kubernetes/blob/master/examples/javaweb-tomcat-sidecar/javaweb.yaml
And for images by default, Kubernetes will pull images from Docker Hub, if not existing in your cluster, and also depends on your ImagePullPolicy
You just need to specify your image at section spec.containers.image
Hope this will help you.