Compare commits
No commits in common. "6694527236fec400709641650a71181c54cb74b9" and "6e5423ffb40a0d1837770fa379a612330e396080" have entirely different histories.
6694527236
...
6e5423ffb4
6 changed files with 25 additions and 81 deletions
|
@ -4,18 +4,6 @@
|
||||||
"local>infrastructure/renovate-config"
|
"local>infrastructure/renovate-config"
|
||||||
],
|
],
|
||||||
"customManagers": [
|
"customManagers": [
|
||||||
{
|
|
||||||
"customType": "regex",
|
|
||||||
"description": "k3s",
|
|
||||||
"fileMatch": [
|
|
||||||
"playbook\\.yml"
|
|
||||||
],
|
|
||||||
"matchStrings": [
|
|
||||||
"\\s+k3s_version:\\s(?<currentValue>.*)"
|
|
||||||
],
|
|
||||||
"depNameTemplate": "k3s-io/k3s",
|
|
||||||
"datasourceTemplate": "github-releases"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"customType": "regex",
|
"customType": "regex",
|
||||||
"description": "ArgoCD",
|
"description": "ArgoCD",
|
||||||
|
|
10
README.md
10
README.md
|
@ -1,4 +1,4 @@
|
||||||
# k3s Kubernetes + ArgoCD + Baseline
|
# k3s Kubernetes + Baseline
|
||||||
|
|
||||||
* [k3s](https://docs.k3s.io/)
|
* [k3s](https://docs.k3s.io/)
|
||||||
* [ArgoCD](https://argoproj.github.io/cd/)
|
* [ArgoCD](https://argoproj.github.io/cd/)
|
||||||
|
@ -10,13 +10,13 @@
|
||||||
* [keel](https://keel.sh)
|
* [keel](https://keel.sh)
|
||||||
* [reloader](https://github.com/stakater/Reloader)
|
* [reloader](https://github.com/stakater/Reloader)
|
||||||
|
|
||||||
## Run (Deploy k3s + ArgoCD + Baseline)
|
## Run (k3s + baseline)
|
||||||
|
|
||||||
`ansible-playbook k3s_boostrap.yml -i <host|ip>,`
|
`docker compose up`
|
||||||
|
|
||||||
### Get kubeconfig
|
### Get kubeconfig
|
||||||
|
|
||||||
`cat /etc/rancher/k3s/k3s.yml`
|
`docker compose exec -it k3s kubectl config view --flatten`
|
||||||
|
|
||||||
### Add Agents
|
### Add Agents
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
> The secure token format (occasionally referred to as a "full" token) contains the following parts:
|
> The secure token format (occasionally referred to as a "full" token) contains the following parts:
|
||||||
>
|
>
|
||||||
> \<prefix\>\<cluster CA hash\>::\<credentials\>
|
> <prefix><cluster CA hash>::<credentials>
|
||||||
|
|
||||||
Get existing server token:
|
Get existing server token:
|
||||||
`cat /var/lib/docker/volumes/baseline_k3s-data/_data/server/token`
|
`cat /var/lib/docker/volumes/baseline_k3s-data/_data/server/token`
|
||||||
|
|
20
docker-compose.yml
Normal file
20
docker-compose.yml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
services:
|
||||||
|
k3s:
|
||||||
|
image: rancher/k3s:v1.30.4-k3s1
|
||||||
|
command:
|
||||||
|
- server
|
||||||
|
- --disable=traefik
|
||||||
|
- --tls-san=k8s.smsvc.net
|
||||||
|
hostname: k8s.smsvc.net
|
||||||
|
restart: always
|
||||||
|
privileged: true
|
||||||
|
cgroup: host
|
||||||
|
network_mode: host
|
||||||
|
volumes:
|
||||||
|
- k3s-data:/var/lib/rancher/k3s/
|
||||||
|
- k3s-run:/run/
|
||||||
|
- ./argocd-bootstrap/:/var/lib/rancher/k3s/server/manifests/argocd-bootstrap/
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
k3s-data:
|
||||||
|
k3s-run:
|
|
@ -6,7 +6,6 @@ metadata:
|
||||||
namespace: cert-manager
|
namespace: cert-manager
|
||||||
annotations:
|
annotations:
|
||||||
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
|
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
|
||||||
argocd.argoproj.io/sync-wave: "2"
|
|
||||||
spec:
|
spec:
|
||||||
acme:
|
acme:
|
||||||
server: https://acme-v02.api.letsencrypt.org/directory
|
server: https://acme-v02.api.letsencrypt.org/directory
|
||||||
|
@ -24,7 +23,6 @@ metadata:
|
||||||
namespace: cert-manager
|
namespace: cert-manager
|
||||||
annotations:
|
annotations:
|
||||||
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
|
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
|
||||||
argocd.argoproj.io/sync-wave: "2"
|
|
||||||
spec:
|
spec:
|
||||||
acme:
|
acme:
|
||||||
server: https://acme-staging-v02.api.letsencrypt.org/directory
|
server: https://acme-staging-v02.api.letsencrypt.org/directory
|
||||||
|
|
|
@ -6,6 +6,5 @@ metadata:
|
||||||
namespace: cert-manager
|
namespace: cert-manager
|
||||||
annotations:
|
annotations:
|
||||||
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
|
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
|
||||||
argocd.argoproj.io/sync-wave: "2"
|
|
||||||
spec:
|
spec:
|
||||||
selfSigned: {}
|
selfSigned: {}
|
||||||
|
|
61
playbook.yml
61
playbook.yml
|
@ -1,61 +0,0 @@
|
||||||
# vim: set ft=yaml.ansible:
|
|
||||||
---
|
|
||||||
- name: Install k3s server
|
|
||||||
hosts: all
|
|
||||||
gather_facts: false
|
|
||||||
tags: k3s-server
|
|
||||||
|
|
||||||
vars:
|
|
||||||
k3s_version: v1.30.4+k3s1
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: Get k3s installed version
|
|
||||||
ansible.builtin.command: k3s --version
|
|
||||||
register: k3s_version_output
|
|
||||||
check_mode: false
|
|
||||||
changed_when: false
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Set k3s installed version
|
|
||||||
when: k3s_version_output.rc == 0
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
installed_k3s_version: "{{ k3s_version_output.stdout_lines[0].split(' ')[2] }}"
|
|
||||||
|
|
||||||
- name: Download and install/update k3s
|
|
||||||
when: (k3s_version_output.rc != 0) or (installed_k3s_version != k3s_version)
|
|
||||||
block:
|
|
||||||
- name: Download K3s install script
|
|
||||||
ansible.builtin.get_url:
|
|
||||||
url: https://get.k3s.io
|
|
||||||
dest: /usr/local/bin/k3s_install.sh
|
|
||||||
mode: "755"
|
|
||||||
- name: Install k3s server
|
|
||||||
ansible.builtin.command: "k3s_install.sh"
|
|
||||||
environment:
|
|
||||||
K3S_NODE_NAME: "{{ inventory_hostname }}"
|
|
||||||
INSTALL_K3S_CHANNEL: "{{ k3s_version }}"
|
|
||||||
INSTALL_K3S_EXEC: "--disable=traefik --tls-san {{ inventory_hostname }}"
|
|
||||||
changed_when: false
|
|
||||||
|
|
||||||
- name: Start and enable k3s server
|
|
||||||
ansible.builtin.service:
|
|
||||||
name: k3s.service
|
|
||||||
state: started
|
|
||||||
enabled: true
|
|
||||||
|
|
||||||
- name: Add restart cronjob
|
|
||||||
ansible.builtin.cron:
|
|
||||||
name: "restart k3s (and regenerate certs if necessary)"
|
|
||||||
special_time: monthly
|
|
||||||
job: "systemctl restart k3s"
|
|
||||||
|
|
||||||
- name: Deploy ArgoCD
|
|
||||||
hosts: all
|
|
||||||
gather_facts: false
|
|
||||||
tags: baseline
|
|
||||||
tasks:
|
|
||||||
- name: Copy manifest
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: argocd-bootstrap/
|
|
||||||
dest: /var/lib/rancher/k3s/server/manifests/argocd-bootstrap/
|
|
||||||
mode: "0755"
|
|
Loading…
Reference in a new issue