commit 0168024b78880ad2d5e6d251d6fda535281a4665
Author: dthaluru <dthaluru@vmware.com>
Date: Tue Jul 28 16:39:16 2015 -0700
Ading kubernetes md file and systemd service file for etcd
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,13 @@ |
| 0 |
+[Unit] |
|
| 1 |
+Description=Etcd Server |
|
| 2 |
+After=network.target |
|
| 3 |
+ |
|
| 4 |
+[Service] |
|
| 5 |
+Type=simple |
|
| 6 |
+WorkingDirectory=/var/lib/etcd/ |
|
| 7 |
+ExecStart=/bin/bash -c "/usr/bin/etcd" |
|
| 8 |
+Restart=on-failure |
|
| 9 |
+LimitNOFILE=65536 |
|
| 10 |
+ |
|
| 11 |
+[Install] |
|
| 12 |
+WantedBy=multi-user.target |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
Summary: Etcd-2.1.1 |
| 2 | 2 |
Name: etcd |
| 3 | 3 |
Version: 2.1.1 |
| 4 |
-Release: 1%{?dist}
|
|
| 4 |
+Release: 2%{?dist}
|
|
| 5 | 5 |
License: Apache License |
| 6 | 6 |
URL: https://github.com/coreos/etcd |
| 7 | 7 |
Group: System Environment/Security |
| ... | ... |
@@ -9,6 +9,7 @@ Vendor: VMware, Inc. |
| 9 | 9 |
Distribution: Photon |
| 10 | 10 |
Source0: https://github.com/coreos/etcd/releases/download/v2.1.1/%{name}-v%{version}-linux-amd64.tar.gz
|
| 11 | 11 |
%define sha1 etcd=d90a29e051f8dea2f5bb4200610ccbcec45497d7 |
| 12 |
+Source1: etcd.service |
|
| 12 | 13 |
Requires: shadow |
| 13 | 14 |
|
| 14 | 15 |
%description |
| ... | ... |
@@ -22,6 +23,7 @@ A highly-available key value store for shared configuration and service discover |
| 22 | 22 |
%install |
| 23 | 23 |
install -vdm755 %{buildroot}%{_bindir}
|
| 24 | 24 |
install -vdm755 %{buildroot}/%{_docdir}/%{name}-%{version}
|
| 25 |
+install -vdm755 %{buildroot}/lib/systemd/system
|
|
| 25 | 26 |
|
| 26 | 27 |
chown -R root:root %{buildroot}%{_bindir}
|
| 27 | 28 |
chown -R root:root %{buildroot}/%{_docdir}/%{name}-%{version}
|
| ... | ... |
@@ -31,6 +33,9 @@ mv %{_builddir}/%{name}-v%{version}-linux-amd64/etcdctl %{buildroot}%{_bindir}/
|
| 31 | 31 |
mv %{_builddir}/%{name}-v%{version}-linux-amd64/README.md %{buildroot}/%{_docdir}/%{name}-%{version}/
|
| 32 | 32 |
mv %{_builddir}/%{name}-v%{version}-linux-amd64/README-etcdctl.md %{buildroot}/%{_docdir}/%{name}-%{version}/
|
| 33 | 33 |
|
| 34 |
+cp %{SOURCE1} %{buildroot}/lib/systemd/system
|
|
| 35 |
+install -vdm755 %{buildroot}/var/lib/etcd
|
|
| 36 |
+ |
|
| 34 | 37 |
%check |
| 35 | 38 |
make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
|
| 36 | 39 |
|
| ... | ... |
@@ -44,8 +49,12 @@ rm -rf %{buildroot}/*
|
| 44 | 44 |
%files |
| 45 | 45 |
%{_bindir}/etcd*
|
| 46 | 46 |
/%{_docdir}/%{name}-%{version}/*
|
| 47 |
+/lib/systemd/system/etcd.service |
|
| 48 |
+%dir /var/lib/etcd |
|
| 47 | 49 |
|
| 48 | 50 |
%changelog |
| 51 |
+* Tue Jul 28 2015 Divya Thaluru <dthaluru@vmware.com> 2.1.1-2 |
|
| 52 |
+- Adding etcd service file |
|
| 49 | 53 |
* Tue Jul 21 2015 Vinay Kulkarni <kulkarniv@vmware.com> 2.1.1-1 |
| 50 | 54 |
- Update to version etcd v2.1.1 |
| 51 | 55 |
* Tue Mar 10 2015 Divya Thaluru <dthaluru@vmware.com> 2.0.4-1 |
| 52 | 56 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,191 @@ |
| 0 |
+Running Kubernetes on Photon |
|
| 1 |
+----------------------------------------------------- |
|
| 2 |
+ |
|
| 3 |
+(Note: Modified Getting started Kubernetes docs accordingly to run Kubernetes on Photon) |
|
| 4 |
+ |
|
| 5 |
+**Table of Contents** |
|
| 6 |
+ |
|
| 7 |
+- [Prerequisites](#prerequisites) |
|
| 8 |
+- [Instructions](#instructions) |
|
| 9 |
+ |
|
| 10 |
+## Prerequisites |
|
| 11 |
+ |
|
| 12 |
+1. You need 2 or more machines with Photon installed. |
|
| 13 |
+ |
|
| 14 |
+## Instructions |
|
| 15 |
+ |
|
| 16 |
+This is a getting started guide for Photon. It is a manual configuration so you understand all the underlying packages / services / ports, etc... |
|
| 17 |
+ |
|
| 18 |
+This guide will only get ONE node (previously minion) working. |
|
| 19 |
+ |
|
| 20 |
+The Kubernetes package provides a few services: kube-apiserver, kube-scheduler, kube-controller-manager, kubelet, kube-proxy. These services are managed by systemd and the configuration resides in a central location: /etc/kubernetes. We will break the services up between the hosts. The first host, photon-master, will be the Kubernetes master. This host will run the kube-apiserver, kube-controller-manager, and kube-scheduler. In addition, the master will also run _etcd_ (not needed if _etcd_ runs on a different host but this guide assumes that _etcd_ and Kubernetes master run on the same host). The remaining host, photon-node will be the node and run kubelet, proxy and docker. |
|
| 21 |
+ |
|
| 22 |
+**System Information:** |
|
| 23 |
+ |
|
| 24 |
+Hosts: |
|
| 25 |
+ |
|
| 26 |
+``` |
|
| 27 |
+photon-master = 192.168.121.9 |
|
| 28 |
+photon-node = 192.168.121.65 |
|
| 29 |
+``` |
|
| 30 |
+ |
|
| 31 |
+**Prepare the hosts:** |
|
| 32 |
+ |
|
| 33 |
+* Install Kubernetes on all hosts - photon-{master,node}.
|
|
| 34 |
+ |
|
| 35 |
+```sh |
|
| 36 |
+tdnf install kubernetes |
|
| 37 |
+``` |
|
| 38 |
+ |
|
| 39 |
+* Install etcd and iptables on photon-master |
|
| 40 |
+ |
|
| 41 |
+```sh |
|
| 42 |
+tdnf install etcd iptables |
|
| 43 |
+``` |
|
| 44 |
+ |
|
| 45 |
+* Install docker on photon-node |
|
| 46 |
+ |
|
| 47 |
+```sh |
|
| 48 |
+tdnf install docker |
|
| 49 |
+``` |
|
| 50 |
+ |
|
| 51 |
+* Add master and node to /etc/hosts on all machines (not needed if hostnames already in DNS). Make sure that communication works between photon-master and photon-node by using a utility such as ping. |
|
| 52 |
+ |
|
| 53 |
+```sh |
|
| 54 |
+echo "192.168.121.9 photon-master |
|
| 55 |
+192.168.121.65 photon-node" >> /etc/hosts |
|
| 56 |
+``` |
|
| 57 |
+ |
|
| 58 |
+* Edit /etc/kubernetes/config which will be the same on all hosts (master and node) to contain: |
|
| 59 |
+ |
|
| 60 |
+```sh |
|
| 61 |
+# Comma separated list of nodes in the etcd cluster |
|
| 62 |
+KUBE_MASTER="--master=http://photon-master:8080" |
|
| 63 |
+ |
|
| 64 |
+# logging to stderr means we get it in the systemd journal |
|
| 65 |
+KUBE_LOGTOSTDERR="--logtostderr=true" |
|
| 66 |
+ |
|
| 67 |
+# journal message level, 0 is debug |
|
| 68 |
+KUBE_LOG_LEVEL="--v=0" |
|
| 69 |
+ |
|
| 70 |
+# Should this cluster be allowed to run privileged docker containers |
|
| 71 |
+KUBE_ALLOW_PRIV="--allow_privileged=false" |
|
| 72 |
+``` |
|
| 73 |
+ |
|
| 74 |
+**Configure the Kubernetes services on the master.** |
|
| 75 |
+ |
|
| 76 |
+* Edit /etc/kubernetes/apiserver to appear as such. The service_cluster_ip_range IP addresses must be an unused block of addresses, not used anywhere else. They do not need to be routed or assigned to anything. |
|
| 77 |
+ |
|
| 78 |
+```sh |
|
| 79 |
+# The address on the local server to listen to. |
|
| 80 |
+KUBE_API_ADDRESS="--address=0.0.0.0" |
|
| 81 |
+ |
|
| 82 |
+# Comma separated list of nodes in the etcd cluster |
|
| 83 |
+KUBE_ETCD_SERVERS="--etcd_servers=http://127.0.0.1:4001" |
|
| 84 |
+ |
|
| 85 |
+# Address range to use for services |
|
| 86 |
+KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16" |
|
| 87 |
+ |
|
| 88 |
+# Add your own! |
|
| 89 |
+KUBE_API_ARGS="" |
|
| 90 |
+``` |
|
| 91 |
+ |
|
| 92 |
+* Start the appropriate services on master: |
|
| 93 |
+ |
|
| 94 |
+```sh |
|
| 95 |
+for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do |
|
| 96 |
+ systemctl restart $SERVICES |
|
| 97 |
+ systemctl enable $SERVICES |
|
| 98 |
+ systemctl status $SERVICES |
|
| 99 |
+done |
|
| 100 |
+``` |
|
| 101 |
+ |
|
| 102 |
+* Addition of nodes: |
|
| 103 |
+ |
|
| 104 |
+* Create following node.json file on Kubernetes master node: |
|
| 105 |
+ |
|
| 106 |
+```json |
|
| 107 |
+{
|
|
| 108 |
+ "apiVersion": "v1", |
|
| 109 |
+ "kind": "Node", |
|
| 110 |
+ "metadata": {
|
|
| 111 |
+ "name": "photon-node", |
|
| 112 |
+ "labels":{ "name": "photon-node-label"}
|
|
| 113 |
+ }, |
|
| 114 |
+ "spec": {
|
|
| 115 |
+ "externalID": "photon-node" |
|
| 116 |
+ } |
|
| 117 |
+} |
|
| 118 |
+``` |
|
| 119 |
+ |
|
| 120 |
+Now create a node object internally in your Kubernetes cluster by running: |
|
| 121 |
+ |
|
| 122 |
+```console |
|
| 123 |
+$ kubectl create -f ./node.json |
|
| 124 |
+ |
|
| 125 |
+$ kubectl get nodes |
|
| 126 |
+NAME LABELS STATUS |
|
| 127 |
+photon-node name=photon-node-label Unknown |
|
| 128 |
+``` |
|
| 129 |
+ |
|
| 130 |
+Please note that in the above, it only creates a representation for the node |
|
| 131 |
+_photon-node_ internally. It does not provision the actual _photon-node_. Also, it |
|
| 132 |
+is assumed that _photon-node_ (as specified in `name`) can be resolved and is |
|
| 133 |
+reachable from Kubernetes master node. This guide will discuss how to provision |
|
| 134 |
+a Kubernetes node (photon-node) below. |
|
| 135 |
+ |
|
| 136 |
+**Configure the Kubernetes services on the node.** |
|
| 137 |
+ |
|
| 138 |
+***We need to configure the kubelet on the node.*** |
|
| 139 |
+ |
|
| 140 |
+* Edit /etc/kubernetes/kubelet to appear as such: |
|
| 141 |
+ |
|
| 142 |
+```sh |
|
| 143 |
+### |
|
| 144 |
+# Kubernetes kubelet (node) config |
|
| 145 |
+ |
|
| 146 |
+# The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces) |
|
| 147 |
+KUBELET_ADDRESS="--address=0.0.0.0" |
|
| 148 |
+ |
|
| 149 |
+# You may leave this blank to use the actual hostname |
|
| 150 |
+KUBELET_HOSTNAME="--hostname_override=photon-node" |
|
| 151 |
+ |
|
| 152 |
+# location of the api-server |
|
| 153 |
+KUBELET_API_SERVER="--api_servers=http://photon-master:8080" |
|
| 154 |
+ |
|
| 155 |
+# Add your own! |
|
| 156 |
+#KUBELET_ARGS="" |
|
| 157 |
+``` |
|
| 158 |
+ |
|
| 159 |
+* Start the appropriate services on the node (photon-node). |
|
| 160 |
+ |
|
| 161 |
+```sh |
|
| 162 |
+for SERVICES in kube-proxy kubelet docker; do |
|
| 163 |
+ systemctl restart $SERVICES |
|
| 164 |
+ systemctl enable $SERVICES |
|
| 165 |
+ systemctl status $SERVICES |
|
| 166 |
+done |
|
| 167 |
+``` |
|
| 168 |
+ |
|
| 169 |
+* Check to make sure now the cluster can see the photon-node on photon-master, and its status changes to _Ready_. |
|
| 170 |
+ |
|
| 171 |
+```console |
|
| 172 |
+kubectl get nodes |
|
| 173 |
+NAME LABELS STATUS |
|
| 174 |
+photon-node name=photon-node-label Ready |
|
| 175 |
+``` |
|
| 176 |
+ |
|
| 177 |
+* Deletion of nodes: |
|
| 178 |
+ |
|
| 179 |
+To delete _photon-node_ from your Kubernetes cluster, one should run the following on photon-master (Please do not do it, it is just for information): |
|
| 180 |
+ |
|
| 181 |
+```sh |
|
| 182 |
+kubectl delete -f ./node.json |
|
| 183 |
+``` |
|
| 184 |
+ |
|
| 185 |
+*You should be finished!* |
|
| 186 |
+ |
|
| 187 |
+**The cluster should be running! Launch a test pod.** |
|
| 188 |
+ |
|
| 189 |
+You should have a functional cluster, check out [101](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/user-guide/walkthrough/README.md)! |
|
| 190 |
+ |