You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+60-14Lines changed: 60 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,9 +32,6 @@ This module installs and configures [Kubernetes](https://kubernetes.io/) which i
32
32
33
33
To bootstrap a Kubernetes cluster in a secure and extensible way, this module uses the [kubeadm](https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/) toolkit.
34
34
35
-
36
-
37
-
38
35
## Setup
39
36
40
37
[Install](https://puppet.com/docs/puppet/5.5/modules_installing.html) this module, [generate the configuration](#generating-the-module-configuration), [add the OS and hostname yaml files to Hiera](#adding-the-`{$OS}.yaml`-and-`{$hostname}.yaml`-files-to-Hiera), and [configure your node](#configuring-your-node).
@@ -51,13 +48,13 @@ The Kubetool Docker image takes each parameter as an environment variable.
51
48
52
49
To output a yaml file into your working directory that corresponds to the operating system you want Kubernetes to run on, and for each controller node, run either of these `docker run` commands:
53
50
54
-
```
51
+
```console
55
52
docker run --rm -v $(pwd):/mnt --env-file env puppet/kubetool:{$module_version}
56
53
```
57
54
58
55
The `docker run` command above includes an `env` file which is included in the root folder of this repo.
Add the `{$OS}.yaml` file to the same [control repo](https://puppet.com/docs/pe/2018.1/control_repo.html) where your [Hiera](https://puppet.com/docs/hiera) data is, usually the `data` directory. By leveraging location facts, such as the [pp_datacenter](https://puppet.com/docs/puppet/5.5/ssl_attributes_extensions.html#reference-5482)[trusted fact](https://puppet.com/docs/puppet/5.5/lang_facts_and_builtin_vars.html#trusted-facts), each cluster can be allocated its own configuration.
85
82
83
+
#### Possible Error fetching hiera data
84
+
85
+
If the below error is encounterd
86
+
87
+
```console
88
+
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Class[Kubernetes]:
89
+
parameter 'api_server_count' expects an Integer value, got Undef
90
+
parameter 'token' expects a String value, got Undef
91
+
parameter 'discovery_token_hash' expects a String value, got Undef (file: /etc/puppetlabs/code/environments/production/manifests/site.pp, line: 138, column: 3) on node xxx.example.local
92
+
```
93
+
94
+
It means that hiera is not getting the values from the associated yaml files stored in the [data folder](./data) so it sets some of the required values as Undefined.
95
+
96
+
Check your [hiera.yaml](./hiera.yaml) file and ensure that it contains entries for `{OS}.yaml` and `{$hostname}.yaml`
97
+
98
+
```ruby
99
+
hierarchy:
100
+
-name:"Family"
101
+
path:Debian.yaml
102
+
-name:"Host"
103
+
path: xxx.example.local.yaml
104
+
```
105
+
86
106
### Configuring your node
87
107
88
108
After the `{$OS}.yaml` and `{$hostname}.yaml` files have been added to the Hiera directory on your Puppet server, configure your node as the controller or worker.
89
109
90
110
A controller node contains the control plane and etcd. In a production cluster, you should have three, five, or seven controllers. A worker node runs your applications. You can add as many worker nodes as Kubernetes can handle. For information about nodes in Kubernetes, see the [Kubernetes documentation](https://kubernetes.io/docs/concepts/architecture/nodes/#what-is-a-node).
91
111
92
-
**Note:**: A node cannot be a controller and a worker. It must be one or the other.
112
+
**Note:** A node cannot be a controller and a worker. It must be one or the other.
93
113
94
114
To make a node a controller, add the following code to the manifest:
95
115
@@ -107,6 +127,27 @@ class {'kubernetes':
107
127
}
108
128
```
109
129
130
+
#### Installing Kubernetes on different OS
131
+
132
+
Currently, `puppetlab-kubernetes` is compatible with Ubuntu Xenial. For different OS, below parameters can be assigned.
133
+
134
+
For instance, installing `kubernetes` version `1.20.0` on Debian `buster`
# Different available version can be found by apt-cache madison docker-ce
145
+
docker_version => '5:20.10.5~3-0~debian-buster',
146
+
docker_package_name => 'docker-ce',
147
+
# Kubernetes Version
148
+
kubernetes_version => '1.20.0',
149
+
```
150
+
110
151
### Validating and unit testing the module
111
152
112
153
This module is compliant with the Puppet Development Kit [(PDK)](https://puppet.com/docs/pdk/1.x/pdk.html), which provides tools to help run unit tests on the module and validate the modules's metadata, syntax, and style.
@@ -116,27 +157,27 @@ unit tests against this module using the [`pdk validate`](https://puppet.com/doc
116
157
117
158
To validate the metadata.json file, run the following command:
118
159
119
-
```
160
+
```console
120
161
pdk validate metadata --puppet-version='5.3.6'
121
162
```
122
163
123
164
To validate the Puppet code and syntax, run the following command:
124
165
125
-
```
166
+
```console
126
167
pdk validate puppet --puppet-version='5.3.6'
127
168
```
128
169
129
170
**Note:** The `pdk validate ruby` command ignores the excluded directories specified in the .rubocop.yml file. Therefore, to validate the Ruby code style and syntax you must specify the directory the code exists in.
130
171
131
172
In the following example we validate the Ruby code contained in the lib directory:
132
173
133
-
```
174
+
```console
134
175
pdk validate ruby lib --puppet-version='5.3.6'
135
176
```
136
177
137
178
To unit test the module, run the following command:
138
179
139
-
```
180
+
```console
140
181
pdk test unit --puppet-version='5.3.6'
141
182
```
142
183
@@ -331,7 +372,7 @@ Valid values are `true`, `false`.
331
372
Defaults to `true`.
332
373
333
374
#### `manage_kernel_modules`
334
-
375
+
335
376
Specifies whether to manage the kernel modules needed for kubernetes
336
377
337
378
Valid values are `true`, `false`.
@@ -375,8 +416,9 @@ Defaults to `main`.
375
416
Specifies the version of the Docker runtime to install.
376
417
377
418
Defaults to:
378
-
-`17.03.0.ce-1.el7.centos` on RedHat.
379
-
-`17.03.0~ce-0~ubuntu-xenial` on Ubuntu.
419
+
420
+
*`17.03.0.ce-1.el7.centos` on RedHat.
421
+
*`17.03.0~ce-0~ubuntu-xenial` on Ubuntu.
380
422
381
423
#### `docker_package_name`
382
424
@@ -445,6 +487,7 @@ The download URL for the etcd archive.
445
487
Defaults to `https://github.com/coreos/etcd/releases/download/v${etcd_version}/${etcd_archive}`.
446
488
447
489
#### `etcd_install_method`
490
+
448
491
The method on how to install etcd. Can be either `wget` (using etcd_source) or `package` (using $etcd_package_name)
449
492
450
493
Defaults to `wget`.
@@ -490,6 +533,7 @@ Defaults to `new`
490
533
Specifies how etcd lists the peers to connect to the cluster.
491
534
492
535
A Hiera example is `kubernetes::etcd_peers`:
536
+
493
537
* 172.17.10.101
494
538
* 172.17.10.102
495
539
* 172.17.10.103
@@ -757,7 +801,8 @@ Docker is the supported container runtime for this module.
757
801
If you would like to contribute to this module, please follow the rules in the [CONTRIBUTING.md](https://github.com/puppetlabs/puppetlabs-kubernetes/blob/main/CONTRIBUTING.md). For more information, see our [module contribution guide.](https://puppet.com/docs/puppet/latest/contributing.html)
758
802
759
803
To run the acceptance tests you can use Puppet Litmus with the Vagrant provider by using the following commands:
For more information about Litmus please see [the wiki](https://github.com/puppetlabs/puppet_litmus/wiki).
771
817
772
818
As currently Litmus does not allow memory size and cpu size parameters for the Vagrant provisioner task we recommend to manually update the Vagrantfile used by the provisioner and add at least the following specifications for the puppetlabs-kubernetes module acceptance tests:
0 commit comments