| 1 |
A Kubernetes cluster with Heat |
| 2 |
============================== |
| 3 |
|
| 4 |
These [Heat][] templates will deploy a [Kubernetes][] cluster that |
| 5 |
supports automatic scaling based on CPU load. |
| 6 |
|
| 7 |
[heat]: https://wiki.openstack.org/wiki/Heat |
| 8 |
[kubernetes]: https://github.com/GoogleCloudPlatform/kubernetes |
| 9 |
|
| 10 |
The cluster uses [Flannel][] to provide an overlay network connecting |
| 11 |
pods deployed on different minions. |
| 12 |
|
| 13 |
[flannel]: https://github.com/coreos/flannel |
| 14 |
|
| 15 |
## Requirements |
| 16 |
|
| 17 |
### Guest image |
| 18 |
|
| 19 |
These templates will work with either openSUSE JeOS or SLES JeOS images |
| 20 |
that are prepared for Docker and Kubernetes. |
| 21 |
|
| 22 |
You can enable docker registry v2 by setting the "registry_enabled" |
| 23 |
parameter to "true". |
| 24 |
|
| 25 |
## Creating the stack |
| 26 |
|
| 27 |
Creating an environment file `local.yaml` with parameters specific to |
| 28 |
your environment: |
| 29 |
|
| 30 |
parameters: |
| 31 |
ssh_key_name: testkey |
| 32 |
external_network: public |
| 33 |
dns_nameserver: 192.168.200.1 |
| 34 |
server_image: openSUSELeap42.1-jeos-k8s |
| 35 |
registry_enabled: true |
| 36 |
registry_username: username |
| 37 |
registry_password: password |
| 38 |
registry_domain: domain |
| 39 |
registry_trust_id: trust_id |
| 40 |
registry_auth_url: auth_url |
| 41 |
registry_region: region |
| 42 |
registry_container: container |
| 43 |
|
| 44 |
And then create the stack, referencing that environment file: |
| 45 |
|
| 46 |
heat stack-create -f kubecluster.yaml -e local.yaml my-kube-cluster |
| 47 |
|
| 48 |
You must provide values for: |
| 49 |
|
| 50 |
- `ssh_key_name` |
| 51 |
- `server_image` |
| 52 |
|
| 53 |
If you enable docker registry v2, you must provide values for: |
| 54 |
|
| 55 |
- `registry_username` |
| 56 |
- `registry_password` |
| 57 |
- `registry_domain` |
| 58 |
- `registry_trust_id` |
| 59 |
- `registry_auth_url` |
| 60 |
- `registry_region` |
| 61 |
- `registry_container |
| 62 |
|
| 63 |
## Interacting with Kubernetes |
| 64 |
|
| 65 |
You can get the ip address of the Kubernetes master using the `heat |
| 66 |
output-show` command: |
| 67 |
|
| 68 |
$ heat output-show my-kube-cluster kube_masters |
| 69 |
"192.168.200.86" |
| 70 |
|
| 71 |
You can ssh into that server as the `minion` user: |
| 72 |
|
| 73 |
$ ssh [email protected] |
| 74 |
|
| 75 |
And once logged in you can run `kubectl`, etc: |
| 76 |
|
| 77 |
$ kubectl get minions |
| 78 |
NAME LABELS STATUS |
| 79 |
10.0.0.4 <none> Ready |
| 80 |
|
| 81 |
You can log into your minions using the `minion` user as well. You |
| 82 |
can get a list of minion addresses by running: |
| 83 |
|
| 84 |
$ heat output-show my-kube-cluster kube_minions |
| 85 |
[ |
| 86 |
"192.168.200.182" |
| 87 |
] |
| 88 |
|
| 89 |
You can get the docker registry v2 address: |
| 90 |
$ heat output-show my-kube-cluster registry_address |
| 91 |
localhost:5000 |
| 92 |
|
| 93 |
## Testing |
| 94 |
|
| 95 |
The templates install an example Pod and Service description into |
| 96 |
`/etc/kubernetes/examples`. You can deploy this with the following |
| 97 |
commands: |
| 98 |
|
| 99 |
$ kubectl create -f /etc/kubernetes/examples/web.service |
| 100 |
$ kubectl create -f /etc/kubernetes/examples/web.pod |
| 101 |
|
| 102 |
This will deploy a minimal webserver and a service. You can use |
| 103 |
`kubectl get pods` and `kubectl get services` to see the results of |
| 104 |
these commands. |
| 105 |
|
| 106 |
## License |
| 107 |
|
| 108 |
Copyright 2016 SUSE Linux GmbH |
| 109 |
|
| 110 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 111 |
you may not use these files except in compliance with the License. |
| 112 |
You may obtain a copy of the License at |
| 113 |
|
| 114 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 115 |
|
| 116 |
Unless required by applicable law or agreed to in writing, software |
| 117 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 118 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 119 |
See the License for the specific language governing permissions and |
| 120 |
limitations under the License. |
| 121 |
|
| 122 |
## Contributing |
| 123 |
|
| 124 |
Please submit bugs and pull requests via the Gerrit repository at |
| 125 |
https://review.openstack.org/. For more information, please refer |
| 126 |
to the following resources: |
| 127 |
|
| 128 |
* **Documentation:** https://docs.openstack.org/magnum/latest/ |
| 129 |
* **Source:** https://opendev.org/openstack/magnum |