geerlingguy / ansible-for-kubernetes

Ansible and Kubernetes examples from Ansible for Kubernetes Book
https://www.ansibleforkubernetes.com
MIT License
691 stars 314 forks source link

Work along issues & notes (eBook version 2020-09-01) #95

Open bonsi opened 3 years ago

bonsi commented 3 years ago

Posting issues, notes & suggestions as I'm working along through the book:

My system:

❯ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:    20.04
Codename:   focal
❯ minikube version
minikube version: v1.18.0
commit: ec61815d60f66a6e4f6353030a40b12362557caa-dirty

Chapter 1

On Ubuntu, minikube start now uses "docker" as the default driver, and not "virtualbox" which you imply in the sections afterwards. To use "virtualbox" as the driver, one would need to run minikube start --driver=virtualbox. On subsequent minikube starts, the selected driver is saved in ~/.minikube and doesn't need to be specified anymore.

Chapter 2

Section: Installing Ansible

Chapter 3

Writing a Playbook to Build a Container Image

Chapter 4

A Vagrantfile for local Infrastructure-as-Code

Running the cluster build playbook

Testing the cluster with a deployment using Ansible

Patching Flannel to use the right network interface

Chapter 5

Authenticating to the EKS Cluster via kubeconfig

The aws-iam-authenticator is no longer required when using aws-cli version 1.16.156 or later

Chapter 6

(TODO in book)

Chapter 7

Manage Kind with Molecule

The default YAML files generated with molecule init scenario seem to have changed (quite a bit). Following along and making changes as suggested result in molecule test throwing an error:

TASK [Gathering Facts] *********************************************************
fatal: [molecule-test]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname molecule-test: Name or service not known", "unreachable": true}

I suspect this has to do with the absent connection: local in converge.yml because after I modified converge.yml as outlined in the next subchapter of the book ("Test a playbook in Kind with Molecule"), the error went away.

Test a playbook in Kind with Molecule

molecule converge successfully runs (docker ps shows me a running container kindest/node:v1.20.2) but if I run kubectl get job hello after that, I get an error:

The connection to the server localhost:8080 was refused - did you specify the right host or port?

Seems like the new kubeconfig (~/.kube/config-molecule-test) is not being used. Solved that by running export KUBECONFIG=~/.kube/config-molecule-test

Kubernetes CI Testing in GitHub Actions


Groetjes, Ivo

blakethepatton commented 2 years ago

I would add that for chapter 2 I encountered issues running the playbook, specifically:

TASK [Create a Deployment for Hello Go.] *** fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "Failed to get client due to HTTPConnectionPool(host='localhost', port=80): Max retries exceeded with url: /version (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f4f9c9daf40>: Failed to establish a new connection: [Errno 111] Connection refused'))"}

Tracked the issue down to my version of ansible installed, described here: https://github.com/kubernetes-client/python/issues/1333

Solution was to update my install of ansible:

sudo apt unstall ansible
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt update
sudo apt install ansible

After updating, things worked.