本地 kubernetes dashboard访问路径 https://kubernetes.local/
本地nexus访问路径 http://nexus.local/
本地kibana访问路径 http://kibana.local/app/home
本地grafana访问路径 http://grafana.local/
本地 kubernetes dashboard访问路径 https://kubernetes.local/
本地nexus访问路径 http://nexus.local/
本地kibana访问路径 http://kibana.local/app/home
本地grafana访问路径 http://grafana.local/
K3S 默认安装 Traefik 作为ingress 控制器
默认没有开启dashboard 且 占用了各个node的80 和 443 端口
traefix配置在kube-system 命名空间内
一个例子 暴露8081 的nexus-service
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: nexus-ingress
namespace: nexus
spec:
entryPoints:
- web
routes:
- match: Host(`nexus.local`) # 域名
kind: Rule
services:
- name: nexus-service
port: 8081
curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn K3S_URL=https://myserver:6443 K3S_TOKEN=mynodetoken sh
或者用我的 脚本install-agent 来安装
http://gitea.robinluo.top/robin/robin-k8s-yaml-script/src/branch/master/192.168.0.34
amd64 拉取 sonatype/nexus
arm64 拉取 klo2k/nexus3
镜像默认开放8081 挂载目录/nexus-data
默认 admin密码 在容器内部 cat nexus-data/admin.password
K3S token
NAME:
k3s token - Manage bootstrap tokens
USAGE:
k3s token command [command options] [arguments...]
COMMANDS:
create Create bootstrap tokens on the server
delete Delete bootstrap tokens on the server
generate Generate and print a bootstrap token, but do not create it on the server
list List bootstrap tokens on the server
OPTIONS:
--help, -h show help
查看log sudo k3s kubectl logs -f -n kubernetes-dashboard kubernetes-dashboard-758765f476-x8rc7 应用 yaml sudo k3s kubectl apply -f XXX.yaml 查看所有资源 sudo k3s kubectl get all --all-name-spaces 删除命名空间 sudo k3s kubectl delete ns XXXXX 进入容器命令行 sudo k3s kubectl exec -it nexus-deployment-87b59d446-ht7p4 -n nexus - /bin/bash 创建命名空间 sudo k3s kubectl create namespace logging
列出镜像 sudo k3s ctr i list
删除本地镜像 sudo k3s ctr i rm registry.cn-hangzhou.aliyuncs.com/robinluo/robinluo:v2.0.4
拉取镜像 sudo k3s ctr i pull registry.cn-hangzhou.aliyuncs.com/robinluo/robinluo:v2.0.4 –plain-http
–plain-http 可指定使用 http拉取镜像
ctr -n k8s.io images pull –platform linux/amd64 my-image:my-tag
镜像打tag sudo k3s ctr i tag registry.cn-hangzhou.aliyuncs.com/robinluo/robinluo:v2.0.4 new tag
导入docker 导出的镜像 ctr i import image.tar
设置mirror
/etc/rancher/k3s/registries.yaml
mirrors:
"docker.io":
endpoint:
- "https://registry.cn-hangzhou.aliyuncs.com"
mirrors:
"my-registry.com":
endpoint:
- "https://my-registry.com"
configs:
"my-registry.com":
auth:
username: user
password: password
另一种设置containerd mirror方法
K3s 将会在/var/lib/rancher/k3s/agent/etc/containerd/config.toml中为 containerd 生成 config.toml。[ 建议不要直接对 containerd 的配置文件进行修改,格式十分的严格 ]
如果要对这个文件进行高级设置,你可以在同一目录中创建另一个名为 config.toml.tmpl 的文件,此文件将会代替默认设置。
config.toml.tmpl将被视为 Go 模板文件,并且config.Node结构被传递给模板。此模板示例介绍了如何使用结构来自定义配置文件
[plugins."io.containerd.grpc.v1.cri".registry]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = ["https://------.mirror.aliyuncs.com", "https://registry-1.docker.io"]
补充ctr 命令分为 i image 镜像 c container 容器 t task 任务(进程)
我们可以分别用 task 命令和 container 命令取停止和启动一个容器实例
containerd 是K3S 默认的容器管理工具 类似于docker
日志路径在 /var/lib/rancher/k3s/agent/containerd/containerd.log