*** UPDATE 05/15/2020 ***
I have since learned about Weave’s footloose project, which provides a VM-like experience, but utilizes containers under the covers. Amazing project!
*** Original Post ***
As I dig deeper into Kubernetes it’s been useful to spin up a pod with one of my favorite Operating Systems and review the configuration for that pod. This is super easy to do with kubectl run’s –image option. To create an Ubuntu VM you can pass the ubuntu image name to “–image”
$ kubectl run -it --rm --image=unbuntu ubuntu -- bash
To create a CentOS pod you can use the centos image:
$ kubectl run -it --rm --image=centos centos -- bash
To create a Fedora pod you can use the fedora image:
$ kubectl run -it --rm --image=fedora fedora -- bash
And to create an alpine pod you can use the alpine image:
$ kubectl run -it --rm --image=alpine alpine -- ash
If you want to run a specific version of an OS you can add the version to the image name:
$ kubectl run -it --rm --image=fedora:26 fedora26 -- bash
Once the POD is up you can start reviewing the various Kubernetes objects that were created to support the pod. You can also use the “–dry-run” and output options to view the object that is created and sent to the API server:
$ kubectl run --image=alpine alpine --dry-run -o yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
creationTimestamp: null
labels:
run: alpine
name: alpine
spec:
replicas: 1
selector:
matchLabels:
run: alpine
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
run: alpine
spec:
containers:
- image: alpine
name: alpine
resources: {}
status: {}
The YAML above can be copied to a file, modified and re-deployed with the kubectl create command. This is a fantastic way to tinker with all of the Kubernetes deployment options.