github.com/enmand/kubernetes@v1.2.0-alpha.0/docs/admin/static-pods.md (about) 1 <!-- BEGIN MUNGE: UNVERSIONED_WARNING --> 2 3 <!-- BEGIN STRIP_FOR_RELEASE --> 4 5 <img src="http://kubernetes.io/img/warning.png" alt="WARNING" 6 width="25" height="25"> 7 <img src="http://kubernetes.io/img/warning.png" alt="WARNING" 8 width="25" height="25"> 9 <img src="http://kubernetes.io/img/warning.png" alt="WARNING" 10 width="25" height="25"> 11 <img src="http://kubernetes.io/img/warning.png" alt="WARNING" 12 width="25" height="25"> 13 <img src="http://kubernetes.io/img/warning.png" alt="WARNING" 14 width="25" height="25"> 15 16 <h2>PLEASE NOTE: This document applies to the HEAD of the source tree</h2> 17 18 If you are using a released version of Kubernetes, you should 19 refer to the docs that go with that version. 20 21 <strong> 22 The latest 1.0.x release of this document can be found 23 [here](http://releases.k8s.io/release-1.0/docs/admin/static-pods.md). 24 25 Documentation for other releases can be found at 26 [releases.k8s.io](http://releases.k8s.io). 27 </strong> 28 -- 29 30 <!-- END STRIP_FOR_RELEASE --> 31 32 <!-- END MUNGE: UNVERSIONED_WARNING --> 33 34 # Static pods (deprecated) 35 36 **Static pods are to be deprecated and can be removed in any future Kubernetes release!** 37 38 *Static pod* are managed directly by kubelet daemon on a specific node, without API server observing it. It does not have associated any replication controller, kubelet daemon itself watches it and restarts it when it crashes. There is no health check though. Static pods are always bound to one kubelet daemon and always run on the same node with it. 39 40 Kubelet automatically creates so-called *mirror pod* on Kubernetes API server for each static pod, so the pods are visible there, but they cannot be controlled from the API server. 41 42 ## Static pod creation 43 44 Static pod can be created in two ways: either by using configuration file(s) or by HTTP. 45 46 ### Configuration files 47 48 The configuration files are just standard pod definition in json or yaml format in specific directory. Use `kubelet --config=<the directory>` to start kubelet daemon, which periodically scans the directory and creates/deletes static pods as yaml/json files appear/disappear there. 49 50 For example, this is how to start a simple web server as a static pod: 51 52 1. Choose a node where we want to run the static pod. In this example, it's `my-minion1`. 53 54 ```console 55 [joe@host ~] $ ssh my-minion1 56 ``` 57 58 2. Choose a directory, say `/etc/kubelet.d` and place a web server pod definition there, e.g. `/etc/kubernetes.d/static-web.yaml`: 59 60 ```console 61 [root@my-minion1 ~] $ mkdir /etc/kubernetes.d/ 62 [root@my-minion1 ~] $ cat <<EOF >/etc/kubernetes.d/static-web.yaml 63 apiVersion: v1 64 kind: Pod 65 metadata: 66 name: static-web 67 labels: 68 role: myrole 69 spec: 70 containers: 71 - name: web 72 image: nginx 73 ports: 74 - name: web 75 containerPort: 80 76 protocol: tcp 77 EOF 78 ``` 79 80 2. Configure your kubelet daemon on the node to use this directory by running it with `--config=/etc/kubelet.d/` argument. On Fedora Fedora 21 with Kubernetes 0.17 edit `/etc/kubernetes/kubelet` to include this line: 81 82 ``` 83 KUBELET_ARGS="--cluster-dns=10.254.0.10 --cluster-domain=kube.local --config=/etc/kubelet.d/" 84 ``` 85 86 Instructions for other distributions or Kubernetes installations may vary. 87 88 3. Restart kubelet. On Fedora 21, this is: 89 90 ```console 91 [root@my-minion1 ~] $ systemctl restart kubelet 92 ``` 93 94 ## Pods created via HTTP 95 96 Kubelet periodically downloads a file specified by `--manifest-url=<URL>` argument and interprets it as a json/yaml file with a pod definition. It works the same as `--config=<directory>`, i.e. it's reloaded every now and then and changes are applied to running static pods (see below). 97 98 ## Behavior of static pods 99 100 When kubelet starts, it automatically starts all pods defined in directory specified in `--config=` or `--manifest-url=` arguments, i.e. our static-web. (It may take some time to pull nginx image, be patient…): 101 102 ```console 103 [joe@my-minion1 ~] $ docker ps 104 CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES 105 f6d05272b57e nginx:latest "nginx" 8 minutes ago Up 8 minutes k8s_web.6f802af4_static-web-fk-minion1_default_67e24ed9466ba55986d120c867395f3c_378e5f3c 106 ``` 107 108 If we look at our Kubernetes API server (running on host `my-master`), we see that a new mirror-pod was created there too: 109 110 ```console 111 [joe@host ~] $ ssh my-master 112 [joe@my-master ~] $ kubectl get pods 113 POD IP CONTAINER(S) IMAGE(S) HOST LABELS STATUS CREATED MESSAGE 114 static-web-my-minion1 172.17.0.3 my-minion1/192.168.100.71 role=myrole Running 11 minutes 115 web nginx Running 11 minutes 116 ``` 117 118 Labels from the static pod are propagated into the mirror-pod and can be used as usual for filtering. 119 120 Notice we cannot delete the pod with the API server (e.g. via [`kubectl`](../user-guide/kubectl/kubectl.md) command), kubelet simply won't remove it. 121 122 ```console 123 [joe@my-master ~] $ kubectl delete pod static-web-my-minion1 124 pods/static-web-my-minion1 125 [joe@my-master ~] $ kubectl get pods 126 POD IP CONTAINER(S) IMAGE(S) HOST ... 127 static-web-my-minion1 172.17.0.3 my-minion1/192.168.100.71 ... 128 ``` 129 130 Back to our `my-minion1` host, we can try to stop the container manually and see, that kubelet automatically restarts it in a while: 131 132 ```console 133 [joe@host ~] $ ssh my-minion1 134 [joe@my-minion1 ~] $ docker stop f6d05272b57e 135 [joe@my-minion1 ~] $ sleep 20 136 [joe@my-minion1 ~] $ docker ps 137 CONTAINER ID IMAGE COMMAND CREATED ... 138 5b920cbaf8b1 nginx:latest "nginx -g 'daemon of 2 seconds ago ... 139 ``` 140 141 ## Dynamic addition and removal of static pods 142 143 Running kubelet periodically scans the configured directory (`/etc/kubelet.d` in our example) for changes and adds/removes pods as files appear/disappear in this directory. 144 145 ```console 146 [joe@my-minion1 ~] $ mv /etc/kubernetes.d/static-web.yaml /tmp 147 [joe@my-minion1 ~] $ sleep 20 148 [joe@my-minion1 ~] $ docker ps 149 // no nginx container is running 150 [joe@my-minion1 ~] $ mv /tmp/static-web.yaml /etc/kubernetes.d/ 151 [joe@my-minion1 ~] $ sleep 20 152 [joe@my-minion1 ~] $ docker ps 153 CONTAINER ID IMAGE COMMAND CREATED ... 154 e7a62e3427f1 nginx:latest "nginx -g 'daemon of 27 seconds ago 155 ``` 156 157 158 159 160 161 <!-- BEGIN MUNGE: GENERATED_ANALYTICS --> 162 [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/admin/static-pods.md?pixel)]() 163 <!-- END MUNGE: GENERATED_ANALYTICS -->