# etcd {"level":"warn","ts":"2023-10-05T02:16:52.853273Z","caller":"embed/config.go:673","msg":"Running http and grpc server on single port. This is not recommended for production."} {"level":"info","ts":"2023-10-05T02:16:52.853914Z","caller":"etcdmain/etcd.go:73","msg":"Running: ","args":["etcd"]} {"level":"warn","ts":"2023-10-05T02:16:52.853947Z","caller":"etcdmain/etcd.go:105","msg":"'data-dir' was empty; using default","data-dir":"default.etcd"} {"level":"warn","ts":"2023-10-05T02:16:52.853994Z","caller":"embed/config.go:673","msg":"Running http and grpc server on single port. This is not recommended for production."} {"level":"info","ts":"2023-10-05T02:16:52.854009Z","caller":"embed/etcd.go:127","msg":"configuring peer listeners","listen-peer-urls":["http://localhost:2380"]} ...
常用管理命令
etcd
查看版本信息
# etcd --version etcd Version: 3.5.3 Git SHA: 0452feec7 Go Version: go1.16.15 Go OS/Arch: linux/amd64
注意事项: Ansible 使用字典顺序加载配置文件,如果在不同的配置文件中配置了 parent groups 和 child groups,那么定义 child groups 的配置要先用定义 parent groups 的文件加载,否则 Ansible 加载配置会报错: Unable to parse /path/to/source_of_parent_groups as an inventory source[4]
$ ctr image ls REF TYPE DIGEST SIZE PLATFORMS LABELS docker.io/library/nginx:alpine application/vnd.docker.distribution.manifest.list.v2+json sha256:455c39afebd4d98ef26dd70284aa86e6810b0485af5f4f222b19b89758cabf1e 9.8 MiB linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x -
将镜像挂载到本地目录
$ ctr image mount docker.io/library/nginx:alpine /mnt $ ls /mnt bin docker-entrypoint.d etc lib mnt proc run srv tmp var dev docker-entrypoint.sh home media opt root sbin sys usr
# alias nerdctl='nerdctl --namespace k8s.io' # nerdctl ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4de4c59a8913 registry.k8s.io/kube-controller-manager:v1.32.0 "kube-controller-man…" 2 days ago Up k8s://kube-system/kube-controller-manager-k8s-master/kube-controller-manager 6a9f17dffdb5 registry.k8s.io/pause:3.6 "/pause" 2 days ago Up k8s://kube-system/kube-controller-manager-k8s-master 3ae8ed830b63 registry.k8s.io/kube-scheduler:v1.32.0 "kube-scheduler --au…" 2 days ago Up k8s://kube-system/kube-scheduler-k8s-master/kube-scheduler 0cb15e8f5ac7 registry.k8s.io/pause:3.6 "/pause" 2 days ago Up k8s://kube-system/kube-scheduler-k8s-master 60ea2cfc01c8 registry.k8s.io/pause:3.6 "/pause" 2 days ago Up k8s://kube-system/kube-apiserver-k8s-master eaf781314f4a registry.k8s.io/pause:3.6 "/pause" 2 days ago Up k8s://kube-system/etcd-k8s-master
$ kubectl get pods NAME READY STATUS RESTARTS AGE test-centos7-7cc5dc6987-jz486 0/1 CrashLoopBackOff 8 (111s ago) 17m
查看 Pod 详细信息
$ kubectl describe pod test-centos7-7cc5dc6987-jz486 ... Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 18m default-scheduler Successfully assigned default/test-centos7-7cc5dc6987-jz486 to ops-kubernetes3 Normal Pulled 16m (x5 over 18m) kubelet Container image "centos:centos7.9.2009" already present on machine Normal Created 16m (x5 over 18m) kubelet Created container centos7 Normal Started 16m (x5 over 18m) kubelet Started container centos7 Warning BackOff 3m3s (x71 over 18m) kubelet Back-off restarting failed container
定位中也可以使用 kubectl describe pod 命令检查 Pod 的退出状态码。Kubernetes 中的 Pod ExitCode 状态码是容器退出时返回的退出状态码,这个状态码通常用来指示容器的执行结果,以便 Kubernetes 和相关工具可以根据它来采取后续的操作。以下是一些常见的 ExitCode 状态码说明:
选择 Personal access tokens ,然后点击 Generate new token 。
生成令牌并复制。
gh
Github 命令行工具 gh 常用操作
Login
参考以下示例使用命令 gh auth login 登陆 Github
# gh auth login ? Where do you use GitHub? GitHub.com ? What is your preferred protocol for Git operations on this host? HTTPS ? Authenticate Git with your GitHub credentials? Yes ? How would you like to authenticate GitHub CLI? Paste an authentication token Tip: you can generate a Personal Access Token here https://github.com/settings/tokens The minimum required scopes are 'repo', 'read:org', 'workflow'. ? Paste your authentication token: ********************************************************************************************* - gh config set -h github.com git_protocol https ✓ Configured git protocol ! Authentication credentials saved in plain text ✓ Logged in as user1
查看 Github 认证状态(gh auth status)
# gh auth status github.com ✓ Logged in to github.com account user1 (/root/.config/gh/hosts.yml) - Active account: true - Git operations protocol: https - Token: github_pat_11BP5YWMA0XuC4iSW26eBN_***********************************************************
# systemd-analyze critical-chain The time when unit became active or started is printed after the "@" character. The time the unit took to start is printed after the "+" character.
# cat /etc/sudoers.d/90-cloud-init-users # Created by cloud-init v. 19.4 on Mon, 31 Oct 2022 07:58:58 +0000 # User rules for centos centos ALL=(ALL) NOPASSWD:ALL