183 lines
6.6 KiB
Markdown
183 lines
6.6 KiB
Markdown
# Talos
|
||
|
||
## Что такое Talos?
|
||
|
||
[Talos Linux](https://www.talos.dev/)
|
||
|
||
- Поддерживает **облачные платформы, «голое железо» и платформы виртуализации**
|
||
- Все **управление системой осуществляется через API**. Нет SSH, оболочки или консоли
|
||
- Готовность к работе: **поддерживает одни из крупнейших Kubernetes-кластеров в мире**
|
||
- Проект с открытым исходным кодом от команды [Sidero Labs](https://www.siderolabs.com/)
|
||
|
||
ISO-образы для архитектур amd64 и arm64 доступны на [странице релизов Talos](https://github.com/siderolabs/talos/releases/).
|
||
|
||
[руководству по началу работы](https://www.talos.dev/v1.9/introduction/getting-started/)
|
||
[фабрика по сборке iso](https://factory.talos.dev/)
|
||
|
||
## Софт
|
||
|
||
MacOS:
|
||
|
||
```bash
|
||
brew install siderolabs/tap/talosctl
|
||
brew tap vasyakrg/talostpl && brew install talostpl
|
||
brew install fluxcd/tap/flux
|
||
brew install helm
|
||
```
|
||
|
||
Linux:
|
||
|
||
```bash
|
||
curl -sL https://talos.dev/install | sh
|
||
curl -L -o talostpl "https://github.com/vasyakrg/talostpl/releases/download/$(curl -s https://api.github.com/repos/vasyakrg/talostpl/releases/latest | grep '"tag_name":' | head -1 | cut -d '"' -f4)/talostpl-linux-amd64"
|
||
chmod +x talostpl
|
||
sudo mv talostpl /usr/local/bin/
|
||
curl -s https://fluxcd.io/install.sh | sudo bash
|
||
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
|
||
chmod 700 get_helm.sh
|
||
./get_helm.sh
|
||
```
|
||
|
||
Manual:
|
||
|
||
<https://github.com/siderolabs/talos/releases/>
|
||
<https://github.com/vasyakrg/talostpl>
|
||
<https://fluxcd.io/flux/installation/>
|
||
<https://helm.sh/docs/intro/install/>
|
||
|
||
## Hacks
|
||
|
||
// .zshrc
|
||
export KUBECONFIG=$(find /Users/vasyansk/Configs/.kube -maxdepth 1 -type f -name '*' -not -name 'kubectx' | tr "\n" ":")
|
||
+
|
||
<https://github.com/weibeld/kubectl-ctx>
|
||
|
||
## Локальный кластер
|
||
|
||
нужен установленный docker
|
||
|
||
```bash
|
||
talosctl cluster create --workers 3
|
||
talosctl dashboard --nodes 10.5.0.2
|
||
|
||
talosctl --context talos-default kubeconfig ~/.kube/talos-default.yaml --nodes 10.5.0.2
|
||
```
|
||
|
||
## Общие команды
|
||
|
||
```bash
|
||
talosctl --context talos-default cluster show
|
||
talosctl --context talos-default processes -w --nodes 10.5.0.2
|
||
talosctl --context talos-default --nodes 10.5.0.2 usage
|
||
talosctl --context talos-default --nodes 10.5.0.2 pcap
|
||
talosctl --context talos-default --nodes 10.5.0.2 netstat -nlpt
|
||
|
||
talosctl --context talos-default --nodes 10.5.0.2 edit machineconfig
|
||
|
||
talosctl --context talos-default --nodes 10.5.0.2 get rd
|
||
talosctl --context talos-default --nodes 10.5.0.2 get routes
|
||
talosctl --context talos-default --nodes 10.5.0.2 get mounts
|
||
talosctl --context talos-default --nodes 10.5.0.2 get cpu
|
||
talosctl --context talos-default --nodes 10.5.0.2 get systemdisk
|
||
talosctl --context talos-default --nodes 10.5.0.2 get etcdmember
|
||
```
|
||
|
||
## Удаление
|
||
|
||
```bash
|
||
talosctl --context talos-default cluster destroy
|
||
rm ~/.kube/talos-default.yaml
|
||
rm ~/.talos/config
|
||
```
|
||
|
||
## Генерация и установка
|
||
|
||
эту часть делает утилита talostpl
|
||
|
||
```bash
|
||
talosctl gen secrets -o config/secrets.yaml
|
||
|
||
talosctl gen config --kubernetes-version 1.33.2 --with-secrets secrets.yaml talos-demo https://192.168.23.57:6443 --config-patch @patch.yaml
|
||
|
||
talosctl machineconfig patch controlplane.yaml --patch @cp1.patch --output cp1.yaml
|
||
talosctl machineconfig patch controlplane.yaml --patch @cp2.patch --output cp2.yaml
|
||
talosctl machineconfig patch controlplane.yaml --patch @cp3.patch --output cp3.yaml
|
||
|
||
talosctl machineconfig patch worker.yaml --patch @worker1.patch --output worker1.yaml
|
||
talosctl machineconfig patch worker.yaml --patch @worker2.patch --output worker2.yaml
|
||
|
||
talosctl apply-config --insecure -n 192.168.23.57 --file cp1.yaml
|
||
talosctl bootstrap --nodes 192.168.23.57 --endpoints 192.168.23.57 --talosconfig=talosconfig
|
||
|
||
# talosctl apply-config --insecure -n 192.168.23.52 --file config/cp2.yaml
|
||
# talosctl apply-config --insecure -n 192.168.23.53 --file config/cp3.yaml
|
||
|
||
talosctl apply-config --insecure -n 192.168.23.63 --file config/worker1.yaml
|
||
talosctl apply-config --insecure -n 192.168.23.64 --file config/worker2.yaml
|
||
|
||
talosctl kubeconfig ~/.kube/talos-demo.yaml --nodes 192.168.23.57 --endpoints 192.168.23.57 --talosconfig talosconfig
|
||
```
|
||
|
||
## Cilium
|
||
|
||
правим api-адрес t8s в cilium/values.yaml
|
||
|
||
```bash
|
||
helm repo add cilium https://helm.cilium.io/
|
||
helm repo update
|
||
|
||
helm upgrade \
|
||
--install \
|
||
cilium \
|
||
cilium/cilium \
|
||
--version 1.17.5 \
|
||
--namespace kube-system \
|
||
--values cilium/values.yaml \
|
||
--set cluster.name=talos-demo \
|
||
--set cluster.id=1
|
||
|
||
kubectl apply -f cilium/ippool.yaml
|
||
kubectl apply -f cilium/l2-announcement-policy.yaml
|
||
```
|
||
|
||
## Re-Apply configs
|
||
|
||
```bash
|
||
talosctl --talosconfig talosconfig apply-config -n 192.168.23.57 --file cp1.yaml
|
||
# talosctl --talosconfig config/talosconfig apply-config -n 192.168.23.52 --file config/cp2.yaml
|
||
# talosctl --talosconfig config/talosconfig apply-config -n 192.168.23.53 --file config/cp3.yaml
|
||
|
||
talosctl --talosconfig config/talosconfig apply-config -n 192.168.23.59 --file config/worker1.yaml
|
||
talosctl --talosconfig config/talosconfig apply-config -n 192.168.23.58 --file config/worker2.yaml
|
||
```
|
||
|
||
## Re-Apply configs and reboot
|
||
|
||
```bash
|
||
talosctl --talosconfig config/talosconfig apply-config -n 192.168.23.57 --file config/cp1.yaml --mode=reboot
|
||
# talosctl --talosconfig config/talosconfig apply-config -n 192.168.23.52 --file config/cp2.yaml --mode=reboot
|
||
# talosctl --talosconfig config/talosconfig apply-config -n 192.168.23.53 --file config/cp3.yaml --mode=reboot
|
||
|
||
talosctl --talosconfig config/talosconfig apply-config -n 192.168.23.59 --file config/worker1.yaml --mode=reboot
|
||
talosctl --talosconfig config/talosconfig apply-config -n 192.168.23.58 --file config/worker2.yaml --mode=reboot
|
||
```
|
||
|
||
## Upgrade
|
||
|
||
```bash
|
||
IMAGE=factory.talos.dev/metal-installer/956b9107edd250304169d2e7a765cdd4e0c31f9097036e2e113b042e6c01bb98:v1.10.4
|
||
|
||
talosctl --talosconfig config/talosconfig upgrade --nodes 192.168.23.54 --image ${IMAGE}
|
||
# talosctl --talosconfig config/talosconfig upgrade --nodes 192.168.23.52 --image ${IMAGE}
|
||
# talosctl --talosconfig config/talosconfig upgrade --nodes 192.168.23.53 --image ${IMAGE}
|
||
|
||
talosctl --talosconfig config/talosconfig upgrade --nodes 192.168.23.55 --image ${IMAGE}
|
||
talosctl --talosconfig config/talosconfig upgrade --nodes 192.168.23.56 --image ${IMAGE}
|
||
```
|
||
|
||
## Upgrade k8s
|
||
|
||
```bash
|
||
talosctl --nodes 192.168.23.100 --talosconfig config/talosconfig upgrade-k8s --to 1.33.2
|
||
```
|