mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Stop telling people how to launch a pod. That's what 101 is for.
This commit is contained in:
		@@ -203,106 +203,4 @@ kubectl get minions
 | 
			
		||||
 | 
			
		||||
**The cluster should be running! Launch a test pod.**
 | 
			
		||||
 | 
			
		||||
* Create a file on fed-master called apache.json that looks as such:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
{
 | 
			
		||||
    "apiVersion": "v1beta1",
 | 
			
		||||
    "kind": "Pod",
 | 
			
		||||
    "id": "apache",
 | 
			
		||||
    "namespace": "default",
 | 
			
		||||
    "labels": {
 | 
			
		||||
        "name": "apache"
 | 
			
		||||
    },
 | 
			
		||||
    "desiredState": {
 | 
			
		||||
        "manifest": {
 | 
			
		||||
            "version": "v1beta1",
 | 
			
		||||
            "id": "apache",
 | 
			
		||||
            "volumes": null,
 | 
			
		||||
            "containers": [
 | 
			
		||||
                {
 | 
			
		||||
                    "name": "master",
 | 
			
		||||
                    "image": "fedora/apache",
 | 
			
		||||
                    "ports": [
 | 
			
		||||
                        {
 | 
			
		||||
                            "containerPort": 80,
 | 
			
		||||
                            "hostPort": 80,
 | 
			
		||||
                            "protocol": "TCP"
 | 
			
		||||
                        }
 | 
			
		||||
                    ],
 | 
			
		||||
                }
 | 
			
		||||
            ],
 | 
			
		||||
            "restartPolicy": {
 | 
			
		||||
                "always": {}
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
```       
 | 
			
		||||
 | 
			
		||||
This json file is describing the attributes of the application environment.  For example, it is giving it a "kind", "id", "name", "ports", and "image".  Since the fedora/apache images doesn't exist in our environment yet, it will be pulled down automatically as part of the deployment process.
 | 
			
		||||
 | 
			
		||||
For more information about which options can go in the schema, check out the docs on the kubernetes github page.
 | 
			
		||||
 | 
			
		||||
* Deploy the fedora/apache image via the apache.json file.
 | 
			
		||||
 | 
			
		||||
```       
 | 
			
		||||
kubectl create -f apache.json
 | 
			
		||||
```
 | 
			
		||||
       
 | 
			
		||||
 | 
			
		||||
* You can monitor progress of the operations with these commands:
 | 
			
		||||
On the master (fed-master) -
 | 
			
		||||
 | 
			
		||||
```       
 | 
			
		||||
journalctl -f -l -xn -u kube-apiserver -u etcd -u kube-scheduler
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
* On the minion (fed-minion) -
 | 
			
		||||
 | 
			
		||||
```       
 | 
			
		||||
journalctl -f -l -xn -u kubelet -u kube-proxy -u docker
 | 
			
		||||
```
 | 
			
		||||
       
 | 
			
		||||
 | 
			
		||||
* After the pod is deployed, you can also list the pod.
 | 
			
		||||
 | 
			
		||||
```       
 | 
			
		||||
# /usr/bin/kubectl get pods 
 | 
			
		||||
ID                  IMAGE(S)            HOST                LABELS              STATUS
 | 
			
		||||
apache              fedora/apache       192.168.121.65/     name=apache         Running
 | 
			
		||||
```       
 | 
			
		||||
 | 
			
		||||
The state might be 'Waiting'.  This indicates that docker is still attempting to download and launch the container.
 | 
			
		||||
 | 
			
		||||
* You can get even more information about the pod like this.
 | 
			
		||||
 | 
			
		||||
```       
 | 
			
		||||
kubectl get --output=json pods/apache | python -mjson.tool
 | 
			
		||||
```       
 | 
			
		||||
 | 
			
		||||
* Finally, on the minion (fed-minion), check that the service is available, running, and functioning.
 | 
			
		||||
 | 
			
		||||
```       
 | 
			
		||||
docker images
 | 
			
		||||
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
 | 
			
		||||
kubernetes/pause    latest              6c4579af347b        7 weeks ago         239.8 kB
 | 
			
		||||
fedora/apache       latest              6927a389deb6        3 months ago        450.6 MB
 | 
			
		||||
 | 
			
		||||
docker ps -l
 | 
			
		||||
CONTAINER ID        IMAGE                  COMMAND             CREATED             STATUS              PORTS               NAMES
 | 
			
		||||
05c69c00ea48        fedora/apache:latest   "/run-apache.sh"    2 minutes ago       Up 2 minutes                            k8s--master.3f918229--apache.etcd--8cd6efe6_-_3a95_-_11e4_-_b618_-_5254005318cb--9bb78458
 | 
			
		||||
 | 
			
		||||
curl http://localhost
 | 
			
		||||
Apache
 | 
			
		||||
```       
 | 
			
		||||
 | 
			
		||||
* To delete the container.
 | 
			
		||||
 | 
			
		||||
```       
 | 
			
		||||
# /usr/bin/kubectl --server=http://fed-master:8080 delete pod apache
 | 
			
		||||
```       
 | 
			
		||||
 | 
			
		||||
Of course this just scratches the surface. I recommend you head off to the kubernetes github page and follow the guestbook example.  It's a bit more complicated but should expose you to more functionality.
 | 
			
		||||
 | 
			
		||||
You can play around with other Fedora images by building from Fedora Dockerfiles.
 | 
			
		||||
You should have a functional cluster, check out [101](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/examples/walkthrough/README.md)!
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user