编辑
2023-08-14
笔记
0

目录

minikube
安装
minikube 帮助信息
启动集群
与群集交互
kubectl 帮助信息
查看 Kubernetes Dashboard Web UI

minikube

本地使用的 K8s 集群

minikube is local Kubernetes, focusing on making it easy to learn and develop for Kubernetes.

安装

shell
# 安装 rpm 包 yum install -y https://storage.googleapis.com/minikube/releases/latest/minikube-latest.x86_64.rpm # 安装 deb 包 curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb && sudo dpkg -i minikube_latest_amd64.deb && rm -f minikube_latest_amd64.deb # 安装 Binary 文件 curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm -f minikube-linux-amd64

minikube 帮助信息

minikube 提供并管理针对开发工作流程优化的本地 Kubernetes 集群。 基本命令: start 启动本地 Kubernetes 集群 status 获取本地 Kubernetes 集群状态 stop 停止正在运行的本地 Kubernetes 集群 delete 删除本地的 Kubernetes 集群 dashboard 访问在 minikube 集群中运行的 kubernetes dashboard pause 暂停 Kubernetes unpause 恢复 Kubernetes 镜像命令 docker-env 提供将终端的 docker-cli 指向 minikube 内部 Docker Engine 的说明。(用于直接在 minikube 内构建 docker 镜像) podman-env 配置环境以使用 minikube's Podman service cache 管理 images 缓存 image 管理 images 配置和管理命令: addons 启用或禁用 minikube 插件 config 修改持久配置值 profile 获取或列出当前配置文件(集群) update-context IP或端口更改的情况下更新 kubeconfig 配置文件 网络和连接命令: service 返回用于连接到 service 的 URL tunnel 连接到 LoadBalancer 服务 高级命令: mount 将指定的目录挂载到 minikube ssh 登录到 minikube 环境(用于调试) kubectl 运行与集群版本匹配的 kubectl 二进制文件 node 添加,删除或者列出其他的节点 cp 将指定的文件复制到 minikube 故障排除命令 ssh-key 检索指定节点的 ssh 密钥路径 ssh-host 检索指定节点的 ssh 主机密钥 ip 检索指定节点的IP地址 logs 返回用于调试本地 Kubernetes 集群的日志 update-check 打印当前版本和最新版本 version 打印 minikube 版本 options 显示全局命令行选项列表 (应用于所有命令)。 Other Commands: completion 生成命令补全的 shell 脚本 license 将依赖项的 licenses 输出到一个目录

启动集群

bash
minikube start

与群集交互

  • 已经安装了 kubectl
bash
kubectl get po -A
  • 使用 minikube 下载对应的 kubectl
bash
minikube kubectl -- get po -A # 设置别名方便使用 kubectl cat << EOF >> ~/.bashrc alias kubectl="minikube kubectl --" EOF source ~/.bashrc

kubectl 帮助信息

kubectl controls the Kubernetes cluster manager. Find more information at: https://kubernetes.io/docs/reference/kubectl/ Basic Commands (Beginner): create Create a resource from a file or from stdin expose Take a replication controller, service, deployment or pod and expose it as a new Kubernetes service run Run a particular image on the cluster set Set specific features on objects Basic Commands (Intermediate): explain Get documentation for a resource get Display one or many resources edit Edit a resource on the server delete Delete resources by file names, stdin, resources and names, or by resources and label selector Deploy Commands: rollout Manage the rollout of a resource scale Set a new size for a deployment, replica set, or replication controller autoscale Auto-scale a deployment, replica set, stateful set, or replication controller Cluster Management Commands: certificate Modify certificate resources. cluster-info Display cluster information top Display resource (CPU/memory) usage cordon Mark node as unschedulable uncordon Mark node as schedulable drain Drain node in preparation for maintenance taint Update the taints on one or more nodes Troubleshooting and Debugging Commands: describe Show details of a specific resource or group of resources logs Print the logs for a container in a pod attach Attach to a running container exec Execute a command in a container port-forward Forward one or more local ports to a pod proxy Run a proxy to the Kubernetes API server cp Copy files and directories to and from containers auth Inspect authorization debug Create debugging sessions for troubleshooting workloads and nodes events List events Advanced Commands: diff Diff the live version against a would-be applied version apply Apply a configuration to a resource by file name or stdin patch Update fields of a resource replace Replace a resource by file name or stdin wait Experimental: Wait for a specific condition on one or many resources kustomize Build a kustomization target from a directory or URL Settings Commands: label Update the labels on a resource annotate Update the annotations on a resource completion Output shell completion code for the specified shell (bash, zsh, fish, or powershell) Other Commands: api-resources Print the supported API resources on the server api-versions Print the supported API versions on the server, in the form of "group/version" config Modify kubeconfig files plugin Provides utilities for interacting with plugins version Print the client and server version information Usage: kubectl [flags] [options] Use "kubectl <command> --help" for more information about a given command. Use "kubectl options" for a list of global command-line options (applies to all commands).

查看 Kubernetes Dashboard Web UI

bash
minikube dashboard

本文作者:菜鸟

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 许可协议。转载请注明出处!