Cluster setup and client config
The cluster setup should work reliable now and servers will join after etcd is up. Furthermore, the client configuration will be added to the output directory now. Other files have seen improvements, too. But it is as it is, in heavy development :)main
parent
03b973a868
commit
31d7ff5983
@ -0,0 +1,55 @@
|
||||
# reference: https://git-scm.com/docs/gitignore
|
||||
|
||||
output/*.*
|
||||
!output/.gitkeep
|
||||
|
||||
# ansible
|
||||
*.retry
|
||||
|
||||
# compiled source
|
||||
bin/
|
||||
*.com
|
||||
*.class
|
||||
*.dll
|
||||
*.exe
|
||||
*.o
|
||||
*.so
|
||||
|
||||
# database
|
||||
*.sql
|
||||
*.sqlite
|
||||
|
||||
# lock files
|
||||
*.lock
|
||||
package-lock.json
|
||||
|
||||
# logs
|
||||
logs/
|
||||
*.log
|
||||
|
||||
# OS generated files
|
||||
.DS_Store*
|
||||
ehthumbs.db
|
||||
Icon?
|
||||
Thumbs.db
|
||||
|
||||
# packages
|
||||
*.7z
|
||||
*.dmg
|
||||
*.gz
|
||||
*.iso
|
||||
*.rar
|
||||
*.tar
|
||||
*.zip
|
||||
|
||||
# python
|
||||
*.py[cod]
|
||||
__pycache__/
|
||||
|
||||
# temporary files
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
# Vagrant
|
||||
.vagrant/
|
@ -0,0 +1,64 @@
|
||||
# Ansible for k3s deployment
|
||||
|
||||
An Ansible repository to deploy a k3s kubernetes cluster.
|
||||
|
||||
## Motivation
|
||||
|
||||
Having different shapres of kubernetes on hand is somewhat mandatory for typical
|
||||
DevOps and development tasks.
|
||||
|
||||
## Description
|
||||
|
||||
This repository allows to build different types of k3s kubernetes setups locally
|
||||
and on specified machines.
|
||||
|
||||
### Features
|
||||
|
||||
This section describes the features of the repository.
|
||||
|
||||
#### Cluster location
|
||||
|
||||
You can set up the cluster, wherever you want. You just need to configure the
|
||||
inventory accordingly and you are good to go.
|
||||
|
||||
##### Vagrant
|
||||
|
||||
TBD
|
||||
|
||||
##### Your own machines
|
||||
|
||||
TBD
|
||||
|
||||
#### Cluster Size
|
||||
|
||||
You can build different clusters by changing the amount of servers and agents.
|
||||
Some typical scenarios, you may be interested in, are described below.
|
||||
|
||||
##### Single instance
|
||||
|
||||
A single kubernetes instance is useful for local development and testing. It is
|
||||
similar to microk8s or minikube setups.
|
||||
|
||||
##### HA Setup
|
||||
|
||||
You can setup a high available kubernetes cluster with 3 servers. This is useful
|
||||
to develop kubernetes services, ingress, HA testing and loadbalancer
|
||||
functionality.
|
||||
|
||||
##### Single server, multiple agents
|
||||
|
||||
If you want to test pod affinity, horizontal auto scaling or just want to use
|
||||
multiple agents, you can define one server and multiple agents.
|
||||
|
||||
##### HA Setup with multiple agents
|
||||
|
||||
Define at minimum 3 servers and 1 agent to get a high available setup. This is
|
||||
very close to a production cluster and can be useful to test production setups.
|
||||
|
||||
#### Container deployments
|
||||
|
||||
The repository will offer options to configure some additional scenarios.
|
||||
|
||||
##### TBD
|
||||
|
||||
TBD
|
@ -1,5 +1,6 @@
|
||||
[defaults]
|
||||
use_persistent_connections=true
|
||||
deprecation_warnings=False
|
||||
|
||||
[connection]
|
||||
pipelining=true
|
||||
|
@ -0,0 +1,9 @@
|
||||
---
|
||||
- hosts: "k3s_server1"
|
||||
|
||||
tasks:
|
||||
|
||||
- name: "Just a message"
|
||||
debug:
|
||||
msg: "{{ inventory_hostname }}"
|
||||
...
|
@ -0,0 +1 @@
|
||||
foo
|
@ -1,93 +0,0 @@
|
||||
---
|
||||
- name: "Install Dependencies"
|
||||
ansible.builtin.dnf:
|
||||
name:
|
||||
- "container-selinux"
|
||||
- "selinux-policy-base"
|
||||
state: "present"
|
||||
become: true
|
||||
|
||||
- name: "Install k3s SELinux"
|
||||
ansible.builtin.dnf:
|
||||
name: "https://rpm.rancher.io/k3s/latest/common/centos/7/noarch/k3s-selinux-0.2-1.el7_8.noarch.rpm"
|
||||
disable_gpg_check: true
|
||||
state: "present"
|
||||
become: true
|
||||
|
||||
#- name: "Manage firewalld Service"
|
||||
# ansible.builtin.service:
|
||||
# name: "firewalld.service"
|
||||
# state: "stopped"
|
||||
# enabled: false
|
||||
# become: true
|
||||
|
||||
- name: "Enable IPv4 forwarding"
|
||||
ansible.builtin.sysctl:
|
||||
name: "net.ipv4.ip_forward"
|
||||
value: 1
|
||||
state: "present"
|
||||
reload: true
|
||||
become: true
|
||||
|
||||
- name: "Enable IPv6 forwarding"
|
||||
ansible.builtin.sysctl:
|
||||
name: "net.ipv6.conf.all.forwarding"
|
||||
value: 1
|
||||
state: "present"
|
||||
reload: true
|
||||
become: true
|
||||
|
||||
- name: "Download k3s Binary"
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/k3s"
|
||||
checksum: "sha256:https://github.com/k3s-io/k3s/releases/download/{{ k3s_version }}/sha256sum-amd64.txt"
|
||||
dest: "/usr/local/bin/k3s"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
mode: 0755
|
||||
become: true
|
||||
|
||||
- name: "Create kubectl symlink"
|
||||
ansible.builtin.file:
|
||||
src: "/usr/local/bin/k3s"
|
||||
dest: "/usr/local/bin/kubectl"
|
||||
state: "link"
|
||||
become: true
|
||||
|
||||
- name: "Create crictl symlink"
|
||||
ansible.builtin.file:
|
||||
src: "/usr/local/bin/k3s"
|
||||
dest: "/usr/local/bin/crictl"
|
||||
state: "link"
|
||||
become: true
|
||||
|
||||
- name: "Create ctr symlink"
|
||||
ansible.builtin.file:
|
||||
src: "/usr/local/bin/k3s"
|
||||
dest: "/usr/local/bin/ctr"
|
||||
state: "link"
|
||||
become: true
|
||||
|
||||
- name: "Manage k3s Service Unit File"
|
||||
ansible.builtin.template:
|
||||
src: "k3s.service.j2"
|
||||
dest: "/etc/systemd/system/k3s.service"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
mode: 0644
|
||||
become: true
|
||||
|
||||
- name: "Manage k3s Service"
|
||||
ansible.builtin.systemd:
|
||||
name: "k3s.service"
|
||||
state: "started"
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
become: true
|
||||
|
||||
- name: "Create kubeconfig"
|
||||
ansible.builtin.copy:
|
||||
dest: "kubeconfig"
|
||||
content: "foo"
|
||||
delegate_to: "localhost"
|
||||
...
|
@ -0,0 +1,20 @@
|
||||
apiVersion: v1
|
||||
clusters:
|
||||
- cluster:
|
||||
server: https://{{ ansible_host }}:6443
|
||||
certificate-authority: server-ca.crt
|
||||
name: local
|
||||
contexts:
|
||||
- context:
|
||||
cluster: local
|
||||
namespace: default
|
||||
user: user
|
||||
name: Default
|
||||
current-context: Default
|
||||
kind: Config
|
||||
preferences: {}
|
||||
users:
|
||||
- name: user
|
||||
user:
|
||||
client-certificate: client-admin.crt
|
||||
client-key: client-admin.key
|
Loading…
Reference in New Issue