marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 1 | |
| 2 | ================== |
| 3 | Kubernetes Formula |
| 4 | ================== |
| 5 | |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 6 | Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications. |
| 7 | |
| 8 | This formula deploys production ready Kubernetes and generate Kubernetes manifests as well. |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 9 | |
| 10 | Based on official Kubernetes salt |
| 11 | https://github.com/kubernetes/kubernetes/tree/master/cluster/saltbase |
| 12 | |
| 13 | Extended on Contrail contribution https://github.com/Juniper/kubernetes/blob/opencontrail-integration/docs/getting-started-guides/opencontrail.md |
| 14 | |
| 15 | |
| 16 | Sample pillars |
| 17 | ============== |
| 18 | |
| 19 | .. code-block:: yaml |
| 20 | |
| 21 | kubernetes: |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 22 | master: |
| 23 | addons: |
| 24 | dns: |
| 25 | domain: cluster.local |
| 26 | enabled: true |
| 27 | replicas: 1 |
| 28 | server: 10.254.0.10 |
| 29 | heapster_influxdb: |
| 30 | enabled: true |
| 31 | public_ip: 185.22.97.132 |
| 32 | ui: |
| 33 | enabled: true |
| 34 | public_ip: 185.22.97.131 |
| 35 | admin: |
| 36 | password: password |
| 37 | username: admin |
| 38 | apiserver: |
| 39 | address: 10.0.175.100 |
| 40 | port: 8080 |
| 41 | ca: kubernetes |
| 42 | enabled: true |
| 43 | etcd: |
| 44 | host: 127.0.0.1 |
| 45 | members: |
| 46 | - host: 10.0.175.100 |
| 47 | name: node040 |
| 48 | name: node040 |
| 49 | token: ca939ec9c2a17b0786f6d411fe019e9b |
| 50 | kubelet: |
| 51 | allow_privileged: true |
| 52 | network: |
| 53 | engine: calico |
| 54 | hash: fb5e30ebe6154911a66ec3fb5f1195b2 |
| 55 | private_ip_range: 10.150.0.0/16 |
| 56 | version: v0.19.0 |
| 57 | service_addresses: 10.254.0.0/16 |
| 58 | storage: |
| 59 | engine: glusterfs |
| 60 | members: |
| 61 | - host: 10.0.175.101 |
| 62 | port: 24007 |
| 63 | - host: 10.0.175.102 |
| 64 | port: 24007 |
| 65 | - host: 10.0.175.103 |
| 66 | port: 24007 |
| 67 | port: 24007 |
| 68 | token: |
| 69 | admin: DFvQ8GJ9JD4fKNfuyEddw3rjnFTkUKsv |
| 70 | controller_manager: EreGh6AnWf8DxH8cYavB2zS029PUi7vx |
| 71 | dns: RAFeVSE4UvsCz4gk3KYReuOI5jsZ1Xt3 |
| 72 | kube_proxy: DFvQ8GelB7afH3wClC9romaMPhquyyEe |
| 73 | kubelet: 7bN5hJ9JD4fKjnFTkUKsvVNfuyEddw3r |
| 74 | logging: MJkXKdbgqRmTHSa2ykTaOaMykgO6KcEf |
| 75 | monitoring: hnsj0XqABgrSww7Nqo7UVTSZLJUt2XRd |
| 76 | scheduler: HY1UUxEPpmjW4a1dDLGIANYQp1nZkLDk |
| 77 | version: v1.2.4 |
| 78 | |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 79 | |
| 80 | kubernetes: |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 81 | pool: |
| 82 | address: 0.0.0.0 |
| 83 | allow_privileged: true |
| 84 | ca: kubernetes |
| 85 | cluster_dns: 10.254.0.10 |
| 86 | cluster_domain: cluster.local |
| 87 | enabled: true |
| 88 | kubelet: |
| 89 | allow_privileged: true |
| 90 | config: /etc/kubernetes/manifests |
| 91 | frequency: 5s |
| 92 | master: |
| 93 | apiserver: |
| 94 | members: |
| 95 | - host: 10.0.175.100 |
| 96 | etcd: |
| 97 | members: |
| 98 | - host: 10.0.175.100 |
| 99 | host: 10.0.175.100 |
| 100 | network: |
| 101 | engine: calico |
| 102 | hash: fb5e30ebe6154911a66ec3fb5f1195b2 |
| 103 | version: v0.19.0 |
| 104 | token: |
| 105 | kube_proxy: DFvQ8GelB7afH3wClC9romaMPhquyyEe |
| 106 | kubelet: 7bN5hJ9JD4fKjnFTkUKsvVNfuyEddw3r |
| 107 | version: v1.2.4 |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 108 | |
| 109 | |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 110 | |
| 111 | Kubernetes with OpenContrail network plugin |
| 112 | ------------------------------------------------ |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 113 | |
| 114 | On Master: |
| 115 | |
| 116 | .. code-block:: yaml |
| 117 | |
| 118 | kubernetes: |
| 119 | master: |
| 120 | network: |
| 121 | engine: opencontrail |
| 122 | host: 10.0.170.70 |
| 123 | port: 8082 |
| 124 | default_domain: default-domain |
| 125 | default_project: default-domain:default-project |
| 126 | public_network: default-domain:default-project:Public |
| 127 | public_ip_range: 185.22.97.128/26 |
| 128 | private_ip_range: 10.150.0.0/16 |
| 129 | service_cluster_ip_range: 10.254.0.0/16 |
| 130 | network_label: name |
| 131 | service_label: uses |
| 132 | cluster_service: kube-system/default |
| 133 | network_manager: |
| 134 | image: pupapaik/opencontrail-kube-network-manager |
| 135 | tag: release-1.1-jpa-final-1 |
| 136 | |
| 137 | On pools: |
| 138 | |
| 139 | .. code-block:: yaml |
| 140 | |
| 141 | kubernetes: |
| 142 | pool: |
| 143 | network: |
| 144 | engine: opencontrail |
| 145 | |
| 146 | Kubernetes with Flannel |
| 147 | ----------------------- |
| 148 | |
| 149 | On Master: |
| 150 | |
| 151 | .. code-block:: yaml |
| 152 | |
| 153 | kubernetes: |
| 154 | master: |
| 155 | network: |
| 156 | engine: flannel |
| 157 | common: |
| 158 | network: |
| 159 | engine: flannel |
| 160 | |
| 161 | On pools: |
| 162 | |
| 163 | .. code-block:: yaml |
| 164 | |
| 165 | kubernetes: |
| 166 | pool: |
| 167 | network: |
| 168 | engine: flannel |
| 169 | common: |
| 170 | network: |
| 171 | engine: flannel |
| 172 | |
| 173 | Kubernetes with Calico |
| 174 | ----------------------- |
| 175 | |
| 176 | On Master: |
| 177 | |
| 178 | .. code-block:: yaml |
| 179 | |
| 180 | kubernetes: |
| 181 | master: |
| 182 | network: |
| 183 | engine: calico |
| 184 | |
| 185 | On pools: |
| 186 | |
| 187 | .. code-block:: yaml |
| 188 | |
| 189 | kubernetes: |
| 190 | pool: |
| 191 | network: |
| 192 | engine: calico |
| 193 | |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 194 | Kubernetes with GlusterFS for storage |
| 195 | --------------------------------------------- |
| 196 | |
| 197 | .. code-block:: yaml |
| 198 | |
| 199 | kubernetes: |
| 200 | master |
| 201 | ... |
| 202 | storage: |
| 203 | engine: glusterfs |
| 204 | port: 24007 |
| 205 | members: |
| 206 | - host: 10.0.175.101 |
| 207 | port: 24007 |
| 208 | - host: 10.0.175.102 |
| 209 | port: 24007 |
| 210 | - host: 10.0.175.103 |
| 211 | port: 24007 |
| 212 | ... |
| 213 | |
marco | 45fc1b7 | 2016-07-02 16:11:18 +0200 | [diff] [blame^] | 214 | Kubernetes namespaces |
| 215 | --------------------- |
| 216 | |
| 217 | Create namespace: |
| 218 | |
| 219 | .. code-block:: yaml |
| 220 | |
| 221 | kubernetes: |
| 222 | master |
| 223 | ... |
| 224 | namespace: |
| 225 | kube-system: |
| 226 | enabled: True |
| 227 | namespace2: |
| 228 | enabled: True |
| 229 | namespace3: |
| 230 | enabled: False |
| 231 | ... |
| 232 | |
| 233 | Kubernetes labels |
| 234 | ----------------- |
| 235 | |
| 236 | Create namespace: |
| 237 | |
| 238 | .. code-block:: yaml |
| 239 | |
| 240 | kubernetes: |
| 241 | pool |
| 242 | ... |
| 243 | host: |
| 244 | label: |
| 245 | key01: |
| 246 | value: value01 |
| 247 | enable: True |
| 248 | key02: |
| 249 | value: value02 |
| 250 | enable: False |
| 251 | name: ${linux:system:name} |
| 252 | ... |
| 253 | |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 254 | Kubernetes Service Definitions in pillars |
| 255 | ========================================== |
| 256 | |
| 257 | Following samples show how to generate kubernetes manifest as well and provide single tool for complete infrastructure management. |
| 258 | |
| 259 | Deployment manifest |
| 260 | --------------------- |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 261 | |
| 262 | .. code-block:: yaml |
| 263 | |
| 264 | salt: |
| 265 | control: |
| 266 | enabled: True |
| 267 | hostNetwork: True |
| 268 | service: |
| 269 | memcached: |
| 270 | privileged: True |
| 271 | service: memcached |
| 272 | role: server |
| 273 | type: LoadBalancer |
| 274 | replicas: 3 |
| 275 | kind: Deployment |
| 276 | apiVersion: extensions/v1beta1 |
| 277 | ports: |
| 278 | - port: 8774 |
| 279 | name: nova-api |
| 280 | - port: 8775 |
| 281 | name: nova-metadata |
| 282 | volume: |
| 283 | volume_name: |
| 284 | type: hostPath |
| 285 | mount: /certs |
| 286 | path: /etc/certs |
| 287 | container: |
| 288 | memcached: |
| 289 | image: memcached |
| 290 | tag:2 |
| 291 | ports: |
| 292 | - port: 8774 |
| 293 | name: nova-api |
| 294 | - port: 8775 |
| 295 | name: nova-metadata |
| 296 | variables: |
| 297 | - name: HTTP_TLS_CERTIFICATE: |
| 298 | value: /certs/domain.crt |
| 299 | - name: HTTP_TLS_KEY |
| 300 | value: /certs/domain.key |
| 301 | volumes: |
| 302 | - name: /etc/certs |
| 303 | type: hostPath |
| 304 | mount: /certs |
| 305 | path: /etc/certs |
| 306 | |
| 307 | Volumes |
| 308 | ------- |
| 309 | |
| 310 | hostPath |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 311 | ========== |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 312 | |
| 313 | .. code-block:: yaml |
| 314 | |
| 315 | container: |
| 316 | memcached: |
| 317 | ... |
| 318 | volumes: |
| 319 | - name: /etc/certs |
| 320 | mount: /certs |
| 321 | type: hostPath |
| 322 | path: /etc/certs |
| 323 | |
| 324 | emptyDir |
| 325 | =========== |
| 326 | |
| 327 | .. code-block:: yaml |
| 328 | |
| 329 | container: |
| 330 | memcached: |
| 331 | ... |
| 332 | volumes: |
| 333 | - name: /etc/certs |
| 334 | mount: /certs |
| 335 | type: emptyDir |