Fork the following repository: https://github.com/vfarcic/k8s-specs
git clone <https://github.com/vfarcic/k8s-specs.git>
cd k8s-specs
Create a mongo DB database
kubectl run db --image mongo \\
--generator "run-pod/v1"
If you want to confirm that the pod was created do: kubectl get pods
Note that if you do not see any output right away that is ok; the mongo image is really big so it might take a while to get the pod up and running.
Confirm that the image is running in the cluster
docker container ls -f ancestor=mongo
To delete the pod run
kubectl delete pod db
Delete the pod above since it was not the best way to run the pod.
To look at the pod definition:
cat pod/db.yml
apiVersion: v1 // means the version 1 of the Kubernetes pod API; API version and kind has to be provided -- it is mandatory
kind: Pod
metadata: // the metadata provides information on the pod, it does not specifiy how the pod behaves
name: db
labels:
type: db
vendor: MongoLabs // I assume, who has created the image
spec:
containers:
- name: db
image: mongo:3.3 // image name and tag
command: ["mongod"]
args: ["--rest", "--httpinterface"] // arguments, defined in an array