Files
Cloud-book/Kubernetes/常见命令手册.md
2025-08-27 17:10:05 +08:00

47 lines
2.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

```shell
# 通过 API 生成临时 Token有效期 1 小时)
kubectl create token calico-node -n kube-system --duration=1h
# 检查 Token 有效性
curl -k -H "Authorization: Bearer <TOKEN>" https://<API-SERVER>:6443/api/v1/namespaces/kube-system/pods
# 升级chart
helm upgrade ingress-nginx ./ingress-nginx -n ingress --values ./ingress-nginx/values.yaml
# 清理缓存
sudo killall -HUP mDNSResponder
# 配置主从复制
stop slave;
change master to master_host='mysql-master',master_user='replicator',master_password='replicator123',master_log_file='mysql-bin.000001',master_log_pos=1786;
start slave;
# 清除所有复制配置包括master.info文件
reset slave all;
# 访问业务
[root@master01 resources]# curl -H "host: bbs.iproute.cn" 10.3.202.101:`kubectl get svc/ingress-nginx-controller -n ingress-nginx -o jsonpath="{.spec.ports[?(@.port==80)].nodePort}" -n ingress`
# calicoctl相关命令
[root@master01 ~]# ./calicoctl-linux-amd64 node status
Calico process is running.
IPv4 BGP status
+--------------+-------------------+-------+----------+-------------+
| PEER ADDRESS | PEER TYPE | STATE | SINCE | INFO |
+--------------+-------------------+-------+----------+-------------+
| 10.3.204.101 | node-to-node mesh | up | 05:11:14 | Established |
| 10.3.204.102 | node-to-node mesh | up | 05:12:46 | Established |
+--------------+-------------------+-------+----------+-------------+
[root@master01 ~]# ./calicoctl-linux-amd64 get ipPool --allow-version-mismatch -o wide
NAME CIDR NAT IPIPMODE VXLANMODE DISABLED SELECTOR
default-ipv4-ippool 10.244.0.0/16 true Never Never false all()
[root@master01 ~]# calicoctl ipam show --show-blocks --allow-version-mismatch
[root@master01 ~]# calicoctl ipam show --allow-version-mismatch
+----------+---------------+-----------+------------+-------------+
| GROUPING | CIDR | IPS TOTAL | IPS IN USE | IPS FREE |
+----------+---------------+-----------+------------+-------------+
| IP Pool | 10.244.0.0/16 | 65536 | 2294 (4%) | 63242 (96%) |
+----------+---------------+-----------+------------+-------------+
```