首页 > 其他分享 >k8s常用命令

k8s常用命令

时间:2023-03-31 09:33:40浏览次数:44  
标签:kubectl service -- 常用命令 harbor deployment k8s hello

kubectl get pods --all-namespaces  查看

kubectl get deployment
kubectl get nodes
kubectl get services

kubectl.exe apply -f .\hello-application.yaml   --创建pods
kubectl expose deployment hello-world --type=NodePort --name=node-service  --创建services
kubectl describe service node-service  --查看service详细

kubectl port-forward service/node-service 7080:8080
minikube service node-service


kubectl scale deployment hello-world --replicas 10  --扩容
kubectl autoscale deployment hello-world --min=10 --max=15 --cpu-percent=80  --动态扩容
kubectl set image deployment/hello-world registry.cn-hangzhou.aliyuncs.com/aliyun_google/google-sample-node-hello:1.0=registry.cn-hangzhou.aliyuncs.com/aliyun_google/google-sample-node-hello:1.1  --更新镜像
kubectl rollout undo deployment/hello-world:1.0  --回滚

--minikube启动
minikube start --force --driver=docker --insecure-registry 服务器地址:端口

//创建deployment
kubectl create -f /var/lib/jenkins/kubernetes/answersheetapi/deployment.yml
//删除deployment
kubectl delete deploy/dev-answersheetapi

//删除service
kubectl delete service/service-answersheetapi

//删除configmap
kubectl delete configmap/configmap-answersheetapi


git clone https://github.com/ahmetb/kubectx.git
cp kubectx/kube* /usr/local/bin/
kubens answersheet

//查看pods详细信息
kubectl describe pod dev-answersheetapi


kubectl create secret docker-registry answersheet-registry-harbor \
    --docker-server=harbor服务器地址:端口 --docker-username=admin \
    --docker-password=harbor密码cat ~/.docker/config.json | base64
vim harbor-dev-secret.yaml
apiVersion: v1
kind: Secret
metadata:
  name: harbor-dev-secret
data:
  .dockerconfigjson: base64加密字符串
type: kubernetes.io/dockerconfigjson
kubectl create -f harbor-dev-secret.yaml

 

标签:kubectl,service,--,常用命令,harbor,deployment,k8s,hello
From: https://www.cnblogs.com/wafulo/p/17275192.html

相关文章

  • 《做一个不背锅运维:一篇搞定K8s Ingress》
    Ingress的出现Ingress是一种Kubernetes资源,用于将外部流量路由到Kubernetes集群内的服务。与NodePort相比,它提供了更高级别的路由功能和负载平衡,可以根据HTTP请求的路径、主机名、HTTP方法等来路由流量。因此,可以说Ingress是为了弥补NodePort在流量路由方面的不足而生的。使用No......
  • tmux 常用命令
    1.新建会话tmuxnew-ssn_name2.退出会话ctrl+B+D3.查看所有会话tmuxls4.恢复会话tmuxattach-d-tsn_name注意-d和-t两个命令是不能替换位置的;-d命令是为了防止在不同的终端打开时,会改变窗口的大小。5.关闭会话tmuxkill-session-tsn_name5......
  • docker desktop k8s错误Unable to connect to the server: EOF
    问题当使用DockerDesktop开启Kubernetes之后,在终端执行命令kubectlgetnodes时,出现以下错误:Unabletoconnecttotheserver:EOF根因分析终端执行命令kubectlcluster-info,输出如下:Tofurtherdebuganddiagnoseclusterproblems,use'kubectlcluster-infod......
  • MySQL常用命令
    常用命令:https://blog.csdn.net/qq_38328378/article/details/80858073最详细的:https://blog.csdn.net/qq_34115899/article/details/81190461......
  • 37、K8S-安全机制-CA、User、Cluster
    1、证书信息1.1、简介我们知道,通过kubeadm在创建集群的时候,其中有一步就是:生成kubernetes控制组件的kubeconfig文件及相关的启动配置文件,通过各种conf文件,让不同的组件具备操作相关资源的权限。1.2、位置master1~]#ll/etc/kubernetes/pki/-rw-r--r--1rootroot131......
  • Rabbitmq 集群常用命令集
    1、常用命令如下:查看RabbitMQ服务状态:rabbitmqctlstatus启用web插件:rabbitmq-pluginsenablerabbitmq_management添加页面用户及密码:rabbitmqctladd_useradmin1234......
  • 36、K8S-安全机制-ServiceAccount(SA)
    1、基础知识1.1、场景基础1.1.1、应用场景对于任何一种应用场景,其权限的认证管理都是非常重要的,对于linux系统来说,selinux、防火墙、pam、sudo等等,其核心的目的都是为......
  • Docker常用命令
    Docker命令组成用制定环境运行命令dockerrunubuntu:15.10/bin/echo"Helloworld"#docker:Docker的二进制执行文件。#run:与前面的docker组合来运行一个容器......
  • git 常用命令
    自用命令git命令初始化git ->gitinit1、新项目添加到dev分支中(新项目已放到本地.git所在目录下)(1)有.git的项目目录右键运行GitBashHere(2)在打开的命令窗口中输入......
  • k8s结构设计
    k8s理念声明式API是k8s最核心的设计理念。在k8s中推崇的使用方法是:首先通过一个任务编排对象,比如Pod,Job,CronJob等,描述你试图管理的应用。然后,为它定义一些运维能力对象,比......