marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 1 | |
| 2 | ================== |
| 3 | Kubernetes Formula |
| 4 | ================== |
| 5 | |
Ales Komarek | 9db8af4 | 2017-06-08 11:08:05 +0200 | [diff] [blame] | 6 | Kubernetes is an open-source system for automating deployment, scaling, and |
| 7 | management of containerized applications. This formula deploys production |
| 8 | ready Kubernetes and generate Kubernetes manifests as well. |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 9 | |
| 10 | |
Ales Komarek | 9db8af4 | 2017-06-08 11:08:05 +0200 | [diff] [blame] | 11 | Sample Pillars |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 12 | ============== |
| 13 | |
Tomáš Kukrál | 189da4b | 2017-01-18 14:30:09 +0100 | [diff] [blame] | 14 | **REQUIRED:** Define image to use for hyperkube, CNIs and calicoctl image |
| 15 | |
| 16 | .. code-block:: yaml |
| 17 | |
| 18 | parameters: |
| 19 | kubernetes: |
| 20 | common: |
| 21 | hyperkube: |
Tomáš Kukrál | a636f0e | 2017-03-21 11:09:55 +0100 | [diff] [blame] | 22 | image: gcr.io/google_containers/hyperkube:v1.5.2 |
Tomáš Kukrál | 189da4b | 2017-01-18 14:30:09 +0100 | [diff] [blame] | 23 | pool: |
| 24 | network: |
| 25 | calicoctl: |
| 26 | image: calico/ctl |
| 27 | cni: |
| 28 | image: calico/cni |
| 29 | |
Tomáš Kukrál | 25a64d7 | 2017-03-23 14:14:07 +0100 | [diff] [blame] | 30 | Enable helm-tiller addon |
Tomáš Kukrál | 1b50f77 | 2017-03-23 12:51:32 +0100 | [diff] [blame] | 31 | |
| 32 | .. code-block:: yaml |
| 33 | |
| 34 | parameters: |
| 35 | kubernetes: |
| 36 | master: |
| 37 | addons: |
| 38 | helm: |
| 39 | enabled: true |
| 40 | |
Matthew Mosesohn | bf9d3fb | 2017-05-17 16:17:02 +0300 | [diff] [blame] | 41 | Enable calico-policy addon |
| 42 | |
| 43 | .. code-block:: yaml |
| 44 | |
| 45 | parameters: |
| 46 | kubernetes: |
| 47 | master: |
| 48 | addons: |
| 49 | calico_policy: |
| 50 | enabled: true |
| 51 | |
Tomáš Kukrál | 25a64d7 | 2017-03-23 14:14:07 +0100 | [diff] [blame] | 52 | Enable netchecker addon |
| 53 | |
| 54 | .. code-block:: yaml |
| 55 | |
| 56 | parameters: |
| 57 | kubernetes: |
| 58 | master: |
| 59 | namespace: |
| 60 | netchecker: |
| 61 | enabled: true |
| 62 | addons: |
| 63 | netchecker: |
| 64 | enabled: true |
Tomáš Kukrál | 1b50f77 | 2017-03-23 12:51:32 +0100 | [diff] [blame] | 65 | |
Tomáš Kukrál | f78baa6 | 2017-04-20 16:18:16 +0200 | [diff] [blame] | 66 | Configure service verbosity |
| 67 | |
| 68 | .. code-block:: yaml |
| 69 | |
| 70 | parameters: |
| 71 | kubernetes: |
| 72 | master: |
| 73 | verbosity: 2 |
| 74 | pool: |
| 75 | verbosity: 2 |
| 76 | |
Tomáš Kukrál | aff3526 | 2017-04-18 12:37:45 +0200 | [diff] [blame] | 77 | Enable autoscaler for dns addon. Poll period can be skipped. |
| 78 | |
| 79 | .. code-block:: yaml |
| 80 | |
| 81 | kubernetes: |
| 82 | master: |
| 83 | addons: |
| 84 | dns: |
| 85 | domain: cluster.local |
| 86 | enabled: true |
| 87 | replicas: 1 |
| 88 | server: 10.254.0.10 |
| 89 | autoscaler: |
| 90 | enabled: true |
| 91 | poll-period-seconds: 60 |
| 92 | |
| 93 | |
Tomáš Kukrál | 6ef3f89 | 2017-02-15 12:02:22 +0100 | [diff] [blame] | 94 | Pass aditional parameters to daemons: |
| 95 | |
| 96 | .. code-block:: yaml |
| 97 | |
| 98 | parameters: |
| 99 | kubernetes: |
| 100 | master: |
| 101 | apiserver: |
| 102 | daemon_opts: |
| 103 | storage-backend: pigeon |
| 104 | controller_manager: |
| 105 | daemon_opts: |
| 106 | log-dir: /dev/nulL |
| 107 | pool: |
| 108 | kubelet: |
| 109 | daemon_opts: |
| 110 | max-pods: "6" |
| 111 | |
Tomáš Kukrál | 189da4b | 2017-01-18 14:30:09 +0100 | [diff] [blame] | 112 | |
Ales Komarek | 688a04c | 2016-07-15 15:12:30 +0200 | [diff] [blame] | 113 | Containers on pool definitions in pool.service.local |
| 114 | |
Jakub Pavlik | 7e98532 | 2016-07-17 13:16:15 +0200 | [diff] [blame] | 115 | .. code-block:: yaml |
| 116 | |
| 117 | parameters: |
| 118 | kubernetes: |
| 119 | pool: |
| 120 | service: |
| 121 | local: |
| 122 | enabled: False |
| 123 | service: libvirt |
| 124 | cluster: openstack-compute |
| 125 | namespace: default |
| 126 | role: ${linux:system:name} |
| 127 | type: LoadBalancer |
| 128 | kind: Deployment |
| 129 | apiVersion: extensions/v1beta1 |
| 130 | replicas: 1 |
| 131 | host_pid: True |
| 132 | nodeSelector: |
| 133 | - key: openstack |
| 134 | value: ${linux:system:name} |
| 135 | hostNetwork: True |
| 136 | container: |
| 137 | libvirt-compute: |
| 138 | privileged: True |
| 139 | image: ${_param:docker_repository}/libvirt-compute |
| 140 | tag: ${_param:openstack_container_tag} |
Ales Komarek | 688a04c | 2016-07-15 15:12:30 +0200 | [diff] [blame] | 141 | |
| 142 | Master definition |
| 143 | |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 144 | .. code-block:: yaml |
| 145 | |
| 146 | kubernetes: |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 147 | master: |
| 148 | addons: |
| 149 | dns: |
| 150 | domain: cluster.local |
| 151 | enabled: true |
| 152 | replicas: 1 |
| 153 | server: 10.254.0.10 |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 154 | admin: |
| 155 | password: password |
| 156 | username: admin |
| 157 | apiserver: |
| 158 | address: 10.0.175.100 |
Swann Croiset | ff97efc | 2017-02-23 13:32:33 +0100 | [diff] [blame] | 159 | secure_port: 443 |
| 160 | insecure_address: 127.0.0.1 |
| 161 | insecure_port: 8080 |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 162 | ca: kubernetes |
| 163 | enabled: true |
| 164 | etcd: |
| 165 | host: 127.0.0.1 |
| 166 | members: |
| 167 | - host: 10.0.175.100 |
| 168 | name: node040 |
| 169 | name: node040 |
| 170 | token: ca939ec9c2a17b0786f6d411fe019e9b |
| 171 | kubelet: |
| 172 | allow_privileged: true |
| 173 | network: |
| 174 | engine: calico |
Matthew Mosesohn | 3d8c111 | 2017-06-06 16:25:46 +0300 | [diff] [blame] | 175 | mtu: 1500 |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 176 | hash: fb5e30ebe6154911a66ec3fb5f1195b2 |
| 177 | private_ip_range: 10.150.0.0/16 |
| 178 | version: v0.19.0 |
| 179 | service_addresses: 10.254.0.0/16 |
| 180 | storage: |
| 181 | engine: glusterfs |
| 182 | members: |
| 183 | - host: 10.0.175.101 |
| 184 | port: 24007 |
| 185 | - host: 10.0.175.102 |
| 186 | port: 24007 |
| 187 | - host: 10.0.175.103 |
| 188 | port: 24007 |
| 189 | port: 24007 |
| 190 | token: |
| 191 | admin: DFvQ8GJ9JD4fKNfuyEddw3rjnFTkUKsv |
| 192 | controller_manager: EreGh6AnWf8DxH8cYavB2zS029PUi7vx |
| 193 | dns: RAFeVSE4UvsCz4gk3KYReuOI5jsZ1Xt3 |
| 194 | kube_proxy: DFvQ8GelB7afH3wClC9romaMPhquyyEe |
| 195 | kubelet: 7bN5hJ9JD4fKjnFTkUKsvVNfuyEddw3r |
| 196 | logging: MJkXKdbgqRmTHSa2ykTaOaMykgO6KcEf |
| 197 | monitoring: hnsj0XqABgrSww7Nqo7UVTSZLJUt2XRd |
| 198 | scheduler: HY1UUxEPpmjW4a1dDLGIANYQp1nZkLDk |
| 199 | version: v1.2.4 |
| 200 | |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 201 | |
| 202 | kubernetes: |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 203 | pool: |
| 204 | address: 0.0.0.0 |
| 205 | allow_privileged: true |
| 206 | ca: kubernetes |
| 207 | cluster_dns: 10.254.0.10 |
| 208 | cluster_domain: cluster.local |
| 209 | enabled: true |
| 210 | kubelet: |
| 211 | allow_privileged: true |
| 212 | config: /etc/kubernetes/manifests |
| 213 | frequency: 5s |
| 214 | master: |
| 215 | apiserver: |
| 216 | members: |
| 217 | - host: 10.0.175.100 |
| 218 | etcd: |
| 219 | members: |
| 220 | - host: 10.0.175.100 |
| 221 | host: 10.0.175.100 |
| 222 | network: |
| 223 | engine: calico |
Matthew Mosesohn | 3d8c111 | 2017-06-06 16:25:46 +0300 | [diff] [blame] | 224 | mtu: 1500 |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 225 | hash: fb5e30ebe6154911a66ec3fb5f1195b2 |
| 226 | version: v0.19.0 |
| 227 | token: |
| 228 | kube_proxy: DFvQ8GelB7afH3wClC9romaMPhquyyEe |
| 229 | kubelet: 7bN5hJ9JD4fKjnFTkUKsvVNfuyEddw3r |
| 230 | version: v1.2.4 |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 231 | |
Tomáš Kukrál | bc3623e | 2017-03-23 18:24:06 +0100 | [diff] [blame] | 232 | |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 233 | Kubernetes with OpenContrail network plugin |
| 234 | ------------------------------------------------ |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 235 | |
| 236 | On Master: |
| 237 | |
| 238 | .. code-block:: yaml |
| 239 | |
| 240 | kubernetes: |
| 241 | master: |
| 242 | network: |
| 243 | engine: opencontrail |
| 244 | host: 10.0.170.70 |
| 245 | port: 8082 |
| 246 | default_domain: default-domain |
| 247 | default_project: default-domain:default-project |
| 248 | public_network: default-domain:default-project:Public |
| 249 | public_ip_range: 185.22.97.128/26 |
| 250 | private_ip_range: 10.150.0.0/16 |
| 251 | service_cluster_ip_range: 10.254.0.0/16 |
| 252 | network_label: name |
| 253 | service_label: uses |
| 254 | cluster_service: kube-system/default |
| 255 | network_manager: |
| 256 | image: pupapaik/opencontrail-kube-network-manager |
| 257 | tag: release-1.1-jpa-final-1 |
| 258 | |
| 259 | On pools: |
| 260 | |
| 261 | .. code-block:: yaml |
| 262 | |
| 263 | kubernetes: |
| 264 | pool: |
| 265 | network: |
| 266 | engine: opencontrail |
| 267 | |
Jakub Pavlik | 1cfc1fe | 2016-07-25 11:01:52 +0200 | [diff] [blame] | 268 | Kubernetes control plane running in systemd |
| 269 | ------------------------------------------- |
| 270 | |
Matthew Mosesohn | bf9d3fb | 2017-05-17 16:17:02 +0300 | [diff] [blame] | 271 | By default kube-apiserver, kube-scheduler, kube-controllermanager, kube-proxy, etcd running in docker containers through manifests. For stable production environment this should be run in systemd. |
Jakub Pavlik | 1cfc1fe | 2016-07-25 11:01:52 +0200 | [diff] [blame] | 272 | |
| 273 | .. code-block:: yaml |
| 274 | |
| 275 | kubernetes: |
| 276 | master: |
| 277 | container: false |
| 278 | |
| 279 | kubernetes: |
| 280 | pool: |
| 281 | container: false |
| 282 | |
marco | 055ff85 | 2016-07-27 15:22:33 +0200 | [diff] [blame] | 283 | Because k8s services run under kube user without root privileges, there is need to change secure port for apiserver. |
| 284 | |
| 285 | .. code-block:: yaml |
| 286 | |
| 287 | kubernetes: |
| 288 | master: |
| 289 | apiserver: |
| 290 | secure_port: 8081 |
| 291 | |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 292 | Kubernetes with Flannel |
| 293 | ----------------------- |
| 294 | |
| 295 | On Master: |
| 296 | |
| 297 | .. code-block:: yaml |
| 298 | |
| 299 | kubernetes: |
| 300 | master: |
| 301 | network: |
| 302 | engine: flannel |
Jakub Pavlik | 7e98532 | 2016-07-17 13:16:15 +0200 | [diff] [blame] | 303 | # If you don't register master as node: |
marco | a05621f | 2016-07-14 10:35:24 +0200 | [diff] [blame] | 304 | etcd: |
| 305 | members: |
| 306 | - host: 10.0.175.101 |
| 307 | port: 4001 |
| 308 | - host: 10.0.175.102 |
| 309 | port: 4001 |
| 310 | - host: 10.0.175.103 |
| 311 | port: 4001 |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 312 | common: |
| 313 | network: |
| 314 | engine: flannel |
| 315 | |
| 316 | On pools: |
| 317 | |
| 318 | .. code-block:: yaml |
| 319 | |
| 320 | kubernetes: |
| 321 | pool: |
| 322 | network: |
| 323 | engine: flannel |
marco | a05621f | 2016-07-14 10:35:24 +0200 | [diff] [blame] | 324 | etcd: |
| 325 | members: |
| 326 | - host: 10.0.175.101 |
| 327 | port: 4001 |
| 328 | - host: 10.0.175.102 |
| 329 | port: 4001 |
| 330 | - host: 10.0.175.103 |
| 331 | port: 4001 |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 332 | common: |
| 333 | network: |
| 334 | engine: flannel |
| 335 | |
| 336 | Kubernetes with Calico |
| 337 | ----------------------- |
| 338 | |
| 339 | On Master: |
| 340 | |
| 341 | .. code-block:: yaml |
| 342 | |
| 343 | kubernetes: |
| 344 | master: |
| 345 | network: |
| 346 | engine: calico |
Matthew Mosesohn | 3d8c111 | 2017-06-06 16:25:46 +0300 | [diff] [blame] | 347 | mtu: 1500 |
Jakub Pavlik | 7e98532 | 2016-07-17 13:16:15 +0200 | [diff] [blame] | 348 | # If you don't register master as node: |
marco | a05621f | 2016-07-14 10:35:24 +0200 | [diff] [blame] | 349 | etcd: |
| 350 | members: |
| 351 | - host: 10.0.175.101 |
| 352 | port: 4001 |
| 353 | - host: 10.0.175.102 |
| 354 | port: 4001 |
| 355 | - host: 10.0.175.103 |
| 356 | port: 4001 |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 357 | |
| 358 | On pools: |
| 359 | |
| 360 | .. code-block:: yaml |
| 361 | |
| 362 | kubernetes: |
| 363 | pool: |
| 364 | network: |
| 365 | engine: calico |
Matthew Mosesohn | 3d8c111 | 2017-06-06 16:25:46 +0300 | [diff] [blame] | 366 | mtu: 1500 |
marco | a05621f | 2016-07-14 10:35:24 +0200 | [diff] [blame] | 367 | etcd: |
| 368 | members: |
| 369 | - host: 10.0.175.101 |
| 370 | port: 4001 |
| 371 | - host: 10.0.175.102 |
| 372 | port: 4001 |
| 373 | - host: 10.0.175.103 |
| 374 | port: 4001 |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 375 | |
Tomáš Kukrál | 34c5936 | 2017-03-01 14:00:37 +0100 | [diff] [blame] | 376 | Running with secured etcd: |
| 377 | |
| 378 | .. code-block:: yaml |
| 379 | |
| 380 | kubernetes: |
| 381 | pool: |
| 382 | network: |
| 383 | engine: calico |
Matthew Mosesohn | 3d8c111 | 2017-06-06 16:25:46 +0300 | [diff] [blame] | 384 | mtu: 1500 |
Tomáš Kukrál | 34c5936 | 2017-03-01 14:00:37 +0100 | [diff] [blame] | 385 | etcd: |
| 386 | ssl: |
| 387 | enabled: true |
| 388 | master: |
| 389 | network: |
| 390 | engine: calico |
| 391 | etcd: |
| 392 | ssl: |
| 393 | enabled: true |
| 394 | |
Matthew Mosesohn | bf9d3fb | 2017-05-17 16:17:02 +0300 | [diff] [blame] | 395 | Running with calico-policy controller: |
| 396 | |
| 397 | .. code-block:: yaml |
| 398 | |
| 399 | kubernetes: |
| 400 | pool: |
| 401 | network: |
| 402 | engine: calico |
Matthew Mosesohn | 3d8c111 | 2017-06-06 16:25:46 +0300 | [diff] [blame] | 403 | mtu: 1500 |
Matthew Mosesohn | bf9d3fb | 2017-05-17 16:17:02 +0300 | [diff] [blame] | 404 | addons: |
| 405 | calico_policy: |
| 406 | enabled: true |
| 407 | |
| 408 | master: |
| 409 | network: |
| 410 | engine: calico |
Matthew Mosesohn | 3d8c111 | 2017-06-06 16:25:46 +0300 | [diff] [blame] | 411 | mtu: 1500 |
Matthew Mosesohn | bf9d3fb | 2017-05-17 16:17:02 +0300 | [diff] [blame] | 412 | addons: |
| 413 | calico_policy: |
| 414 | enabled: true |
| 415 | |
| 416 | |
| 417 | |
Tomáš Kukrál | 7e91a94 | 2017-03-23 16:02:52 +0100 | [diff] [blame] | 418 | Enable Prometheus metrics in Felix |
| 419 | |
| 420 | .. code-block:: yaml |
| 421 | |
| 422 | kubernetes: |
| 423 | pool: |
| 424 | network: |
| 425 | prometheus: |
| 426 | enabled: true |
| 427 | master: |
| 428 | network: |
| 429 | prometheus: |
| 430 | enabled: true |
| 431 | |
Jakub Pavlik | 7e98532 | 2016-07-17 13:16:15 +0200 | [diff] [blame] | 432 | Post deployment configuration |
| 433 | |
| 434 | .. code-block:: bash |
Jakub Pavlik | 232833c | 2016-07-17 13:21:00 +0200 | [diff] [blame] | 435 | |
Jakub Pavlik | 7e98532 | 2016-07-17 13:16:15 +0200 | [diff] [blame] | 436 | # set ETCD |
| 437 | export ETCD_AUTHORITY=10.0.111.201:4001 |
| 438 | |
| 439 | # Set NAT for pods subnet |
| 440 | calicoctl pool add 192.168.0.0/16 --nat-outgoing |
| 441 | |
| 442 | # Status commands |
| 443 | calicoctl status |
| 444 | calicoctl node show |
| 445 | |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 446 | Kubernetes with GlusterFS for storage |
| 447 | --------------------------------------------- |
| 448 | |
| 449 | .. code-block:: yaml |
| 450 | |
| 451 | kubernetes: |
Tomáš Kukrál | 4f0dae3 | 2017-03-21 19:04:19 +0100 | [diff] [blame] | 452 | master: |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 453 | ... |
| 454 | storage: |
| 455 | engine: glusterfs |
| 456 | port: 24007 |
| 457 | members: |
| 458 | - host: 10.0.175.101 |
| 459 | port: 24007 |
| 460 | - host: 10.0.175.102 |
| 461 | port: 24007 |
| 462 | - host: 10.0.175.103 |
| 463 | port: 24007 |
| 464 | ... |
| 465 | |
marco | 45fc1b7 | 2016-07-02 16:11:18 +0200 | [diff] [blame] | 466 | Kubernetes namespaces |
| 467 | --------------------- |
| 468 | |
| 469 | Create namespace: |
| 470 | |
| 471 | .. code-block:: yaml |
| 472 | |
| 473 | kubernetes: |
Tomáš Kukrál | 4f0dae3 | 2017-03-21 19:04:19 +0100 | [diff] [blame] | 474 | master: |
marco | 45fc1b7 | 2016-07-02 16:11:18 +0200 | [diff] [blame] | 475 | ... |
| 476 | namespace: |
| 477 | kube-system: |
| 478 | enabled: True |
| 479 | namespace2: |
| 480 | enabled: True |
| 481 | namespace3: |
| 482 | enabled: False |
| 483 | ... |
| 484 | |
| 485 | Kubernetes labels |
| 486 | ----------------- |
| 487 | |
Marek Celoud | 901020b | 2017-01-27 14:51:41 +0100 | [diff] [blame] | 488 | Label node: |
marco | 45fc1b7 | 2016-07-02 16:11:18 +0200 | [diff] [blame] | 489 | |
| 490 | .. code-block:: yaml |
| 491 | |
Marek Celoud | 901020b | 2017-01-27 14:51:41 +0100 | [diff] [blame] | 492 | kubernetes: |
| 493 | master: |
| 494 | label: |
| 495 | label01: |
| 496 | value: value01 |
| 497 | node: node01 |
| 498 | enabled: true |
| 499 | key: key01 |
marco | 45fc1b7 | 2016-07-02 16:11:18 +0200 | [diff] [blame] | 500 | ... |
marco | 45fc1b7 | 2016-07-02 16:11:18 +0200 | [diff] [blame] | 501 | |
marco | f7efecb | 2016-07-16 16:13:37 +0200 | [diff] [blame] | 502 | Pull images from private registries |
| 503 | ----------------------------------- |
| 504 | |
| 505 | .. code-block:: yaml |
| 506 | |
| 507 | kubernetes: |
Tomáš Kukrál | 4f0dae3 | 2017-03-21 19:04:19 +0100 | [diff] [blame] | 508 | master: |
marco | f7efecb | 2016-07-16 16:13:37 +0200 | [diff] [blame] | 509 | ... |
| 510 | registry: |
| 511 | secret: |
| 512 | registry01: |
| 513 | enabled: True |
| 514 | key: (get from `cat /root/.docker/config.json | base64`) |
| 515 | namespace: default |
| 516 | ... |
| 517 | control: |
| 518 | ... |
| 519 | service: |
| 520 | service01: |
| 521 | ... |
| 522 | image_pull_secretes: registry01 |
| 523 | ... |
| 524 | |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 525 | Kubernetes Service Definitions in pillars |
| 526 | ========================================== |
| 527 | |
| 528 | Following samples show how to generate kubernetes manifest as well and provide single tool for complete infrastructure management. |
| 529 | |
| 530 | Deployment manifest |
| 531 | --------------------- |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 532 | |
| 533 | .. code-block:: yaml |
| 534 | |
| 535 | salt: |
| 536 | control: |
| 537 | enabled: True |
| 538 | hostNetwork: True |
| 539 | service: |
| 540 | memcached: |
| 541 | privileged: True |
| 542 | service: memcached |
| 543 | role: server |
| 544 | type: LoadBalancer |
| 545 | replicas: 3 |
| 546 | kind: Deployment |
| 547 | apiVersion: extensions/v1beta1 |
| 548 | ports: |
| 549 | - port: 8774 |
| 550 | name: nova-api |
| 551 | - port: 8775 |
| 552 | name: nova-metadata |
| 553 | volume: |
| 554 | volume_name: |
| 555 | type: hostPath |
| 556 | mount: /certs |
| 557 | path: /etc/certs |
| 558 | container: |
| 559 | memcached: |
| 560 | image: memcached |
| 561 | tag:2 |
| 562 | ports: |
| 563 | - port: 8774 |
| 564 | name: nova-api |
| 565 | - port: 8775 |
| 566 | name: nova-metadata |
| 567 | variables: |
| 568 | - name: HTTP_TLS_CERTIFICATE: |
| 569 | value: /certs/domain.crt |
| 570 | - name: HTTP_TLS_KEY |
| 571 | value: /certs/domain.key |
| 572 | volumes: |
| 573 | - name: /etc/certs |
| 574 | type: hostPath |
| 575 | mount: /certs |
| 576 | path: /etc/certs |
| 577 | |
marco | be30c8d | 2016-10-11 19:16:35 +0200 | [diff] [blame] | 578 | PetSet manifest |
| 579 | --------------------- |
| 580 | |
| 581 | .. code-block:: yaml |
| 582 | |
| 583 | service: |
| 584 | memcached: |
| 585 | apiVersion: apps/v1alpha1 |
| 586 | kind: PetSet |
| 587 | service_name: 'memcached' |
| 588 | container: |
| 589 | memcached: |
| 590 | ... |
| 591 | |
| 592 | |
Filip Pytloun | 9a4a40f | 2016-09-22 16:28:19 +0200 | [diff] [blame] | 593 | Configmap |
| 594 | --------- |
| 595 | |
| 596 | You are able to create configmaps using support layer between formulas. |
| 597 | It works simple, eg. in nova formula there's file ``meta/config.yml`` which |
| 598 | defines config files used by that service and roles. |
| 599 | |
| 600 | Kubernetes formula is able to generate these files using custom pillar and |
| 601 | grains structure. This way you are able to run docker images built by any way |
| 602 | while still re-using your configuration management. |
| 603 | |
| 604 | Example pillar: |
| 605 | |
| 606 | .. code-block:: bash |
| 607 | |
| 608 | kubernetes: |
| 609 | control: |
Jakub Pavlik | a277972 | 2016-11-25 15:35:26 +0100 | [diff] [blame] | 610 | config_type: default|kubernetes # Output is yaml k8s or default single files |
Filip Pytloun | 9a4a40f | 2016-09-22 16:28:19 +0200 | [diff] [blame] | 611 | configmap: |
| 612 | nova-control: |
| 613 | grains: |
| 614 | # Alternate grains as OS running in container may differ from |
| 615 | # salt minion OS. Needed only if grains matters for config |
| 616 | # generation. |
| 617 | os_family: Debian |
| 618 | pillar: |
| 619 | # Generic pillar for nova controller |
| 620 | nova: |
| 621 | controller: |
| 622 | enabled: true |
| 623 | versionn: liberty |
| 624 | ... |
| 625 | |
| 626 | To tell which services supports config generation, you need to ensure pillar |
| 627 | structure like this to determine support: |
| 628 | |
| 629 | .. code-block:: yaml |
| 630 | |
| 631 | nova: |
| 632 | _support: |
| 633 | config: |
| 634 | enabled: true |
| 635 | |
marco | d4d3dbd | 2016-09-27 11:36:40 +0200 | [diff] [blame] | 636 | initContainers |
| 637 | -------------- |
| 638 | |
| 639 | Example pillar: |
| 640 | |
| 641 | .. code-block:: bash |
| 642 | |
| 643 | kubernetes: |
| 644 | control: |
| 645 | service: |
| 646 | memcached: |
| 647 | init_containers: |
| 648 | - name: test-mysql |
| 649 | image: busybox |
| 650 | command: |
| 651 | - sleep |
| 652 | - 3600 |
| 653 | volumes: |
| 654 | - name: config |
| 655 | mount: /test |
| 656 | - name: test-memcached |
| 657 | image: busybox |
| 658 | command: |
| 659 | - sleep |
| 660 | - 3600 |
| 661 | volumes: |
| 662 | - name: config |
| 663 | mount: /test |
| 664 | |
marco | ee859d3 | 2016-11-07 11:04:57 +0100 | [diff] [blame] | 665 | Affinity |
| 666 | -------- |
| 667 | |
| 668 | podAffinity |
| 669 | =========== |
| 670 | |
| 671 | Example pillar: |
| 672 | |
| 673 | .. code-block:: bash |
| 674 | |
| 675 | kubernetes: |
| 676 | control: |
| 677 | service: |
| 678 | memcached: |
| 679 | affinity: |
| 680 | pod_affinity: |
| 681 | name: podAffinity |
| 682 | expression: |
| 683 | label_selector: |
| 684 | name: labelSelector |
| 685 | selectors: |
| 686 | - key: app |
| 687 | value: memcached |
| 688 | topology_key: kubernetes.io/hostname |
| 689 | |
| 690 | podAntiAffinity |
| 691 | =============== |
| 692 | |
| 693 | Example pillar: |
| 694 | |
| 695 | .. code-block:: bash |
| 696 | |
| 697 | kubernetes: |
| 698 | control: |
| 699 | service: |
| 700 | memcached: |
| 701 | affinity: |
| 702 | anti_affinity: |
| 703 | name: podAntiAffinity |
| 704 | expression: |
| 705 | label_selector: |
| 706 | name: labelSelector |
| 707 | selectors: |
| 708 | - key: app |
| 709 | value: opencontrail-control |
| 710 | topology_key: kubernetes.io/hostname |
| 711 | |
| 712 | nodeAffinity |
| 713 | =============== |
| 714 | |
| 715 | Example pillar: |
| 716 | |
| 717 | .. code-block:: bash |
| 718 | |
| 719 | kubernetes: |
| 720 | control: |
| 721 | service: |
| 722 | memcached: |
| 723 | affinity: |
| 724 | node_affinity: |
| 725 | name: nodeAffinity |
| 726 | expression: |
| 727 | match_expressions: |
| 728 | name: matchExpressions |
| 729 | selectors: |
| 730 | - key: key |
| 731 | operator: In |
| 732 | values: |
| 733 | - value1 |
| 734 | - value2 |
| 735 | |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 736 | Volumes |
| 737 | ------- |
| 738 | |
| 739 | hostPath |
Jakub Pavlik | 495d06f | 2016-06-17 11:33:05 +0200 | [diff] [blame] | 740 | ========== |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 741 | |
| 742 | .. code-block:: yaml |
| 743 | |
marco | b469f88 | 2016-09-27 09:56:13 +0200 | [diff] [blame] | 744 | service: |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 745 | memcached: |
marco | b469f88 | 2016-09-27 09:56:13 +0200 | [diff] [blame] | 746 | container: |
| 747 | memcached: |
| 748 | volumes: |
| 749 | - name: volume1 |
| 750 | mountPath: /volume |
| 751 | readOnly: True |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 752 | ... |
marco | b469f88 | 2016-09-27 09:56:13 +0200 | [diff] [blame] | 753 | volume: |
| 754 | volume1: |
| 755 | name: /etc/certs |
| 756 | type: hostPath |
| 757 | path: /etc/certs |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 758 | |
| 759 | emptyDir |
Ales Komarek | 688a04c | 2016-07-15 15:12:30 +0200 | [diff] [blame] | 760 | ======== |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 761 | |
| 762 | .. code-block:: yaml |
| 763 | |
marco | b469f88 | 2016-09-27 09:56:13 +0200 | [diff] [blame] | 764 | service: |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 765 | memcached: |
marco | b469f88 | 2016-09-27 09:56:13 +0200 | [diff] [blame] | 766 | container: |
| 767 | memcached: |
| 768 | volumes: |
| 769 | - name: volume1 |
| 770 | mountPath: /volume |
| 771 | readOnly: True |
marco | acdae7e | 2015-12-02 15:35:37 +0100 | [diff] [blame] | 772 | ... |
marco | b469f88 | 2016-09-27 09:56:13 +0200 | [diff] [blame] | 773 | volume: |
| 774 | volume1: |
| 775 | name: /etc/certs |
| 776 | type: emptyDir |
| 777 | |
| 778 | configMap |
| 779 | ========= |
| 780 | |
| 781 | .. code-block:: yaml |
| 782 | |
| 783 | service: |
| 784 | memcached: |
| 785 | container: |
| 786 | memcached: |
| 787 | volumes: |
| 788 | - name: volume1 |
| 789 | mountPath: /volume |
| 790 | readOnly: True |
| 791 | ... |
| 792 | volume: |
| 793 | volume1: |
| 794 | type: config_map |
| 795 | item: |
| 796 | configMap1: |
| 797 | key: config.conf |
| 798 | path: config.conf |
| 799 | configMap2: |
| 800 | key: policy.json |
| 801 | path: policy.json |
Jakub Pavlik | 27ad3a6 | 2016-08-05 11:39:45 +0200 | [diff] [blame] | 802 | |
marco | 0eda4fb | 2016-10-10 19:08:27 +0200 | [diff] [blame] | 803 | To mount single configuration file instead of whole directory: |
| 804 | |
| 805 | .. code-block:: yaml |
| 806 | |
| 807 | service: |
| 808 | memcached: |
| 809 | container: |
| 810 | memcached: |
| 811 | volumes: |
| 812 | - name: volume1 |
| 813 | mountPath: /volume/config.conf |
| 814 | sub_path: config.conf |
| 815 | |
marco | fcc20d0 | 2016-10-10 09:56:12 +0200 | [diff] [blame] | 816 | Generating Jobs |
| 817 | =============== |
| 818 | |
| 819 | Example pillar: |
| 820 | |
| 821 | .. code-block:: yaml |
| 822 | |
| 823 | kubernetes: |
| 824 | control: |
| 825 | job: |
| 826 | sleep: |
| 827 | job: sleep |
| 828 | restart_policy: Never |
| 829 | container: |
| 830 | sleep: |
| 831 | image: busybox |
| 832 | tag: latest |
| 833 | command: |
| 834 | - sleep |
| 835 | - "3600" |
| 836 | |
| 837 | Volumes and Variables can be used as the same way as during Deployment generation. |
| 838 | |
| 839 | Custom params: |
| 840 | |
| 841 | .. code-block:: yaml |
| 842 | |
| 843 | kubernetes: |
| 844 | control: |
| 845 | job: |
| 846 | host_network: True |
| 847 | host_pid: True |
| 848 | container: |
| 849 | sleep: |
| 850 | privileged: True |
| 851 | node_selector: |
| 852 | key: node |
| 853 | value: one |
| 854 | image_pull_secretes: password |
| 855 | |
Jakub Pavlik | 27ad3a6 | 2016-08-05 11:39:45 +0200 | [diff] [blame] | 856 | |
Ales Komarek | 9db8af4 | 2017-06-08 11:08:05 +0200 | [diff] [blame] | 857 | More Information |
| 858 | ================ |
Jakub Pavlik | 27ad3a6 | 2016-08-05 11:39:45 +0200 | [diff] [blame] | 859 | |
Ales Komarek | 9db8af4 | 2017-06-08 11:08:05 +0200 | [diff] [blame] | 860 | * https://github.com/Juniper/kubernetes/blob |
| 861 | /opencontrail-integration/docs /getting-started-guides/opencontrail.md |
| 862 | * https://github.com/kubernetes/kubernetes/tree/master/cluster/saltbase |
Jakub Pavlik | 27ad3a6 | 2016-08-05 11:39:45 +0200 | [diff] [blame] | 863 | |
Filip Pytloun | d06f627 | 2017-02-02 13:02:03 +0100 | [diff] [blame] | 864 | |
| 865 | Documentation and Bugs |
| 866 | ====================== |
| 867 | |
| 868 | To learn how to install and update salt-formulas, consult the documentation |
| 869 | available online at: |
| 870 | |
| 871 | http://salt-formulas.readthedocs.io/ |
| 872 | |
| 873 | In the unfortunate event that bugs are discovered, they should be reported to |
| 874 | the appropriate issue tracker. Use Github issue tracker for specific salt |
| 875 | formula: |
| 876 | |
| 877 | https://github.com/salt-formulas/salt-formula-kubernetes/issues |
| 878 | |
| 879 | For feature requests, bug reports or blueprints affecting entire ecosystem, |
| 880 | use Launchpad salt-formulas project: |
| 881 | |
| 882 | https://launchpad.net/salt-formulas |
| 883 | |
| 884 | You can also join salt-formulas-users team and subscribe to mailing list: |
| 885 | |
| 886 | https://launchpad.net/~salt-formulas-users |
| 887 | |
| 888 | Developers wishing to work on the salt-formulas projects should always base |
| 889 | their work on master branch and submit pull request against specific formula. |
| 890 | |
| 891 | https://github.com/salt-formulas/salt-formula-kubernetes |
| 892 | |
| 893 | Any questions or feedback is always welcome so feel free to join our IRC |
| 894 | channel: |
| 895 | |
| 896 | #salt-formulas @ irc.freenode.net |