2024-09-02 20:10:32 +00:00
# k3s Kubernetes + Baseline
2021-11-28 22:36:39 +00:00
2024-09-02 20:10:32 +00:00
* [k3s ](https://docs.k3s.io/ )
2022-03-21 09:23:56 +00:00
* [ArgoCD ](https://argoproj.github.io/cd/ )
2022-03-31 15:42:55 +00:00
* [NGINX Ingress Controller ](https://kubernetes.github.io/ingress-nginx/ )
* [cert-manager ](https://cert-manager.io/ )
2022-04-29 13:19:50 +00:00
* selfsigned issuer
2022-05-01 15:33:33 +00:00
* LetsEncrypt issuers (Prod and Staging)
2024-06-20 12:13:31 +00:00
* [zabbix-proxy ](https://git.zabbix.com/projects/ZT/repos/kubernetes-helm/browse?at=refs%2Fheads%2Frelease%2F7.0 )
2022-03-31 15:42:55 +00:00
* [keel ](https://keel.sh )
* [reloader ](https://github.com/stakater/Reloader )
2022-01-05 22:10:37 +00:00
2024-09-02 20:10:32 +00:00
## Run (k3s + baseline)
2022-04-10 09:02:21 +00:00
2024-08-30 22:22:48 +00:00
`docker compose up`
2022-04-10 09:02:21 +00:00
2024-08-30 22:22:48 +00:00
### Get kubeconfig
2022-01-05 22:10:37 +00:00
2024-09-02 20:10:32 +00:00
`docker compose exec -it k3s kubectl config view --flatten`
2022-04-10 09:02:21 +00:00
2024-09-03 20:31:56 +00:00
### Add Agents
#### Get Agent Token
> The secure token format (occasionally referred to as a "full" token) contains the following parts:
>
> <prefix><cluster CA hash>::<credentials>
Get existing server token:
`cat /var/lib/docker/volumes/baseline_k3s-data/_data/server/token`
Create new token:
`docker compose exec -it k3s k3s token create`
#### Register Agent/Worker
```bash
export K3S_URL=https://< cpn.fqdn > :6443
export K3S_NODE_NAME=< node.fqdn >
export K3S_TOKEN=< full-token >
curl -sfL https://get.k3s.io | sh -s -
```
2022-04-10 09:02:21 +00:00
## Notes
2022-02-06 14:43:50 +00:00
2023-07-29 18:13:44 +00:00
### ArgoCD
2023-08-01 21:07:13 +00:00
To retrieve the initial admin password use
`kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d`
2023-07-29 18:13:44 +00:00
2023-08-01 21:07:13 +00:00
To change the password follow [Argocd account update password ](https://argo-cd.readthedocs.io/en/stable/user-guide/commands/argocd_account_update-password/ ).
2023-07-29 18:13:44 +00:00
2024-09-03 11:24:07 +00:00
#### Sync Applications with Kubectl
Add to application:
```yaml
operation:
sync:
syncStrategy:
hook: {}
```
2024-09-03 18:14:09 +00:00
### Zabbix Monitoring
See: [infrastructure/zabbix-config - Zabbix Kubernetes Monitoring ](https://git.smsvc.net/infrastructure/zabbix-config/src/branch/master/Zabbix-Kubernetes.md )
## Cloud Setups
2022-01-05 22:10:37 +00:00
### Linode
2022-02-03 07:30:12 +00:00
PROXY protocol needs to be enabled for ingress-nginx to see the clients IP in ingress log.
2022-01-05 22:10:37 +00:00
2022-02-03 07:30:12 +00:00
Add the PROXY protocol annotation to the ingress-nginx service:
2022-02-03 07:28:40 +00:00
2022-01-05 22:10:37 +00:00
```
annotations:
2022-02-03 07:28:40 +00:00
service.beta.kubernetes.io/linode-loadbalancer-proxy-protocol: v2
2022-01-05 22:10:37 +00:00
```
2022-02-03 07:30:12 +00:00
Update the ingress-nginx ConfigMap to make nginx expect PROXY protocol data:
2022-02-03 07:28:40 +00:00
2022-01-05 22:10:37 +00:00
```
data:
use-proxy-protocol: "true"
```
2022-02-03 07:28:40 +00:00
#### cert-manager
> However, when you have the PROXY protocol enabled, the external load balancer does modify the traffic, prepending the PROXY line before each TCP connection. If you connect directly to the web server internally, bypassing the external load balancer, then it will receive traffic without the PROXY line.
2024-06-20 12:13:31 +00:00
>
2022-02-03 07:28:40 +00:00
> This is particularly a problem when using cert-manager for provisioning SSL certificates.
After enabling the PROXY protocol cert-manager is unable to perform a self check ("propagation check failed", "failed to perform self check GET request").
[hairpin-proxy ](https://github.com/compumike/hairpin-proxy ) adds PROXY protocol support for internal-to-LoadBalancer traffic for Kubernetes Ingress users, specifically for cert-manager self-checks (no further configuration needed).