Skip to content

Commit f220033

Browse files
author
carabasdaniel
authored
Merge pull request #494 from bitvijays/docs_update
Added information about Hiera YAML Lookup; installing a updated version.
2 parents da7a120 + a872026 commit f220033

File tree

1 file changed

+60
-14
lines changed

1 file changed

+60
-14
lines changed

README.md

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ This module installs and configures [Kubernetes](https://kubernetes.io/) which i
3232

3333
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.
3434

35-
36-
37-
3835
## Setup
3936

4037
[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.
5148

5249
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:
5350

54-
```
51+
```console
5552
docker run --rm -v $(pwd):/mnt --env-file env puppet/kubetool:{$module_version}
5653
```
5754

5855
The `docker run` command above includes an `env` file which is included in the root folder of this repo.
5956

60-
```
57+
```console
6158
docker run --rm -v $(pwd):/mnt -e OS=ubuntu -e VERSION=1.10.2 -e CONTAINER_RUNTIME=docker -e CNI_PROVIDER=cilium -e CNI_PROVIDER_VERSION=1.4.3 -e ETCD_INITIAL_CLUSTER=kube-control-plane:172.17.10.101,kube-replica-control-plane-01:172.17.10.210,kube-replica-control-plane-02:172.17.10.220 -e ETCD_IP="%{networking.ip}" -e KUBE_API_ADVERTISE_ADDRESS="%{networking.ip}" -e INSTALL_DASHBOARD=true puppet/kubetool:{$module-version}
6259
```
6360

@@ -83,13 +80,36 @@ Kubetool creates:
8380

8481
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.
8582

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+
86106
### Configuring your node
87107

88108
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.
89109

90110
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).
91111

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.
93113

94114
To make a node a controller, add the following code to the manifest:
95115

@@ -107,6 +127,27 @@ class {'kubernetes':
107127
}
108128
```
109129

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`
135+
136+
```puppet
137+
# Docker repo and key as documented in
138+
# https://docs.docker.com/install/linux/docker-ce/debian/
139+
docker_apt_location => 'https://download.docker.com/linux/debian',
140+
docker_apt_repos => 'stable',
141+
docker_apt_release => 'buster',
142+
docker_key_id => '9DC858229FC7DD38854AE2D88D81803C0EBFCD88',
143+
docker_key_source => 'https://download.docker.com/linux/debian/gpg',
144+
# 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+
110151
### Validating and unit testing the module
111152

112153
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
116157

117158
To validate the metadata.json file, run the following command:
118159

119-
```
160+
```console
120161
pdk validate metadata --puppet-version='5.3.6'
121162
```
122163

123164
To validate the Puppet code and syntax, run the following command:
124165

125-
```
166+
```console
126167
pdk validate puppet --puppet-version='5.3.6'
127168
```
128169

129170
**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.
130171

131172
In the following example we validate the Ruby code contained in the lib directory:
132173

133-
```
174+
```console
134175
pdk validate ruby lib --puppet-version='5.3.6'
135176
```
136177

137178
To unit test the module, run the following command:
138179

139-
```
180+
```console
140181
pdk test unit --puppet-version='5.3.6'
141182
```
142183

@@ -331,7 +372,7 @@ Valid values are `true`, `false`.
331372
Defaults to `true`.
332373

333374
#### `manage_kernel_modules`
334-
375+
335376
Specifies whether to manage the kernel modules needed for kubernetes
336377

337378
Valid values are `true`, `false`.
@@ -375,8 +416,9 @@ Defaults to `main`.
375416
Specifies the version of the Docker runtime to install.
376417

377418
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.
380422

381423
#### `docker_package_name`
382424

@@ -445,6 +487,7 @@ The download URL for the etcd archive.
445487
Defaults to `https://github.com/coreos/etcd/releases/download/v${etcd_version}/${etcd_archive}`.
446488

447489
#### `etcd_install_method`
490+
448491
The method on how to install etcd. Can be either `wget` (using etcd_source) or `package` (using $etcd_package_name)
449492

450493
Defaults to `wget`.
@@ -490,6 +533,7 @@ Defaults to `new`
490533
Specifies how etcd lists the peers to connect to the cluster.
491534

492535
A Hiera example is `kubernetes::etcd_peers`:
536+
493537
* 172.17.10.101
494538
* 172.17.10.102
495539
* 172.17.10.103
@@ -757,7 +801,8 @@ Docker is the supported container runtime for this module.
757801
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)
758802

759803
To run the acceptance tests you can use Puppet Litmus with the Vagrant provider by using the following commands:
760-
```
804+
805+
```console
761806
# install rvm with and ruby >2.5
762807
rvm install "ruby-2.5.1"
763808
gem install bundler
@@ -767,6 +812,7 @@ bundle exec rake 'litmus:install_agent[puppet5]'
767812
bundle exec rake 'litmus:install_module'
768813
bundle exec rake 'litmus:acceptance:parallel'
769814
```
815+
770816
For more information about Litmus please see [the wiki](https://github.com/puppetlabs/puppet_litmus/wiki).
771817

772818
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

Comments
 (0)