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