首页 > 其他分享 >k8s 基础命令

k8s 基础命令

时间:2024-08-26 11:06:54浏览次数:5  
标签:false crd nginx 基础 命令 io k8s true

1. 查看所有api资源

kubectl api-resources
NAME资源名称
SHORTNAMES资源简写
APIGROUPapi组
NAMESPACED命名空间
KIND分类

[root@k8s-master ~]# kubectl api-resources
NAME                              SHORTNAMES   APIGROUP                       NAMESPACED   KIND
bindings                                                                      true         Binding
componentstatuses                 cs                                          false        ComponentStatus
configmaps                        cm                                          true         ConfigMap
endpoints                         ep                                          true         Endpoints
events                            ev                                          true         Event
limitranges                       limits                                      true         LimitRange
namespaces                        ns                                          false        Namespace
nodes                             no                                          false        Node
persistentvolumeclaims            pvc                                         true         PersistentVolumeClaim
persistentvolumes                 pv                                          false        PersistentVolume
pods                              po                                          true         Pod
podtemplates                                                                  true         PodTemplate
replicationcontrollers            rc                                          true         ReplicationController
resourcequotas                    quota                                       true         ResourceQuota
secrets                                                                       true         Secret
serviceaccounts                   sa                                          true         ServiceAccount
services                          svc                                         true         Service
mutatingwebhookconfigurations                  admissionregistration.k8s.io   false        MutatingWebhookConfiguration
validatingwebhookconfigurations                admissionregistration.k8s.io   false        ValidatingWebhookConfiguration
customresourcedefinitions         crd,crds     apiextensions.k8s.io           false        CustomResourceDefinition
apiservices                                    apiregistration.k8s.io         false        APIService
controllerrevisions                            apps                           true         ControllerRevision
daemonsets                        ds           apps                           true         DaemonSet
deployments                       deploy       apps                           true         Deployment
replicasets                       rs           apps                           true         ReplicaSet
statefulsets                      sts          apps                           true         StatefulSet
tokenreviews                                   authentication.k8s.io          false        TokenReview
localsubjectaccessreviews                      authorization.k8s.io           true         LocalSubjectAccessReview
selfsubjectaccessreviews                       authorization.k8s.io           false        SelfSubjectAccessReview
selfsubjectrulesreviews                        authorization.k8s.io           false        SelfSubjectRulesReview
subjectaccessreviews                           authorization.k8s.io           false        SubjectAccessReview
horizontalpodautoscalers          hpa          autoscaling                    true         HorizontalPodAutoscaler
cronjobs                          cj           batch                          true         CronJob
jobs                                           batch                          true         Job
certificatesigningrequests        csr          certificates.k8s.io            false        CertificateSigningRequest
leases                                         coordination.k8s.io            true         Lease
bgpconfigurations                              crd.projectcalico.org          false        BGPConfiguration
bgppeers                                       crd.projectcalico.org          false        BGPPeer
blockaffinities                                crd.projectcalico.org          false        BlockAffinity
clusterinformations                            crd.projectcalico.org          false        ClusterInformation
felixconfigurations                            crd.projectcalico.org          false        FelixConfiguration
globalnetworkpolicies                          crd.projectcalico.org          false        GlobalNetworkPolicy
globalnetworksets                              crd.projectcalico.org          false        GlobalNetworkSet
hostendpoints                                  crd.projectcalico.org          false        HostEndpoint
ipamblocks                                     crd.projectcalico.org          false        IPAMBlock
ipamconfigs                                    crd.projectcalico.org          false        IPAMConfig
ipamhandles                                    crd.projectcalico.org          false        IPAMHandle
ippools                                        crd.projectcalico.org          false        IPPool
kubecontrollersconfigurations                  crd.projectcalico.org          false        KubeControllersConfiguration
networkpolicies                                crd.projectcalico.org          true         NetworkPolicy
networksets                                    crd.projectcalico.org          true         NetworkSet
endpointslices                                 discovery.k8s.io               true         EndpointSlice
events                            ev           events.k8s.io                  true         Event
ingresses                         ing          extensions                     true         Ingress
ingressclasses                                 networking.k8s.io              false        IngressClass
ingresses                         ing          networking.k8s.io              true         Ingress
networkpolicies                   netpol       networking.k8s.io              true         NetworkPolicy
runtimeclasses                                 node.k8s.io                    false        RuntimeClass
poddisruptionbudgets              pdb          policy                         true         PodDisruptionBudget
podsecuritypolicies               psp          policy                         false        PodSecurityPolicy
clusterrolebindings                            rbac.authorization.k8s.io      false        ClusterRoleBinding
clusterroles                                   rbac.authorization.k8s.io      false        ClusterRole
rolebindings                                   rbac.authorization.k8s.io      true         RoleBinding
roles                                          rbac.authorization.k8s.io      true         Role
priorityclasses                   pc           scheduling.k8s.io              false        PriorityClass
csidrivers                                     storage.k8s.io                 false        CSIDriver
csinodes                                       storage.k8s.io                 false        CSINode
storageclasses                    sc           storage.k8s.io                 false        StorageClass
volumeattachments                              storage.k8s.io                 false        VolumeAttachment

2. namespace(命名空间)

  • 所有NAMESPACED的资源,在创建的时候都需要指定namespace,若不指定,默认会在default命名空间下
  • 相同namespace下的同类资源不可以重名,不同类型的资源可以重名
  • 不同namespace下的同类资源可以重名
#查看namespace
[root@k8s-master ~]# kubectl get namespace
NAME              STATUS   AGE
default           Active   38m
kube-node-lease   Active   38m
kube-public       Active   38m
kube-system       Active   38m
#创建namespace
[root@k8s-master ~]# kubectl create namespace test
namespace/test created
[root@k8s-master ~]# 
#删除namespace
[root@k8s-master ~]# kubectl delete namespace test
namespace "test" deleted
[root@k8s-master ~]# kubectl get namespace
NAME              STATUS   AGE
default           Active   48m
kube-node-lease   Active   48m
kube-public       Active   48m
kube-system       Active   48m

3.pod

docker调度的是容器,在k8s集群中,最小的调度单元是Pod,一个pod中可以运行多个容器。
创建nginx pod nginx.yaml

apiVersion: v1 #指定api版本
kind: Pod #指定资源名称
metadata: #定义资源的元数据信息
  name: nginx #
  namespace: nginx #命名空间,需要提前创建
  labels: #标签
    component: nginx #标签名称
spec:
  containers:
  - name: nginx #pod名称
    image: nginx:1.22.0 #镜像地址
    ports: 
    - containerPort: 80 #pod内部容器的端口

创建pod

kubectl create -f nginx.yaml
#查看pod详细信息
kubectl -n nginx get pods
#查看pod调度节点及pod_ip
kubectl -n nginx get pods -o wide
#查看完整的yaml
kubectl -n nginx get pods -o yaml
#查看事件
kubectl -n nginx  describe pods nginx

#根据文件删除
$ kubectl delete -f nginx.yaml

#根据pod_name删除test
$ kubectl -n nginx delete pod nginx

标签:false,crd,nginx,基础,命令,io,k8s,true
From: https://www.cnblogs.com/LI-XinYu/p/17237084.html

相关文章

  • 【K8s】专题十二(3):Kubernetes 存储之 PersistentVolumeClaim
    本文内容均来自个人笔记并重新梳理,如有错误欢迎指正!如果对您有帮助,烦请点赞、关注、转发、订阅专栏!专栏订阅入口Linux专栏 | Docker专栏 | Kubernetes专栏往期精彩文章【Docker】(全网首发)KylinV10下MySQL容器内存占用异常的解决方法【Docker】(全网首发)Kyli......
  • B站宋红康JAVA基础视频教程个人笔记chapter08-09(异常处理+多线程)
    文章目录1.异常处理方式1:try-catch-finally2.异常处理方式1:throws3.程序,进程,线程的区别4.线程的创建4.1线程的创建方式1:4.2线程的创建方式2:5.线程类的常用方法和生命周期5.1线程的生命周期jdk5之前6.线程的安全问题和同步机制6.线程之间的通信6.1为什么需要线程之间......
  • k8s~ServiceAccount_ClusterRole_ClusterRoleBinding
    apisix的k8s服务发现配置命名空间权限是基于KubernetesRBAC能力的授权,通过权限设置可以让不同的用户或用户组拥有操作不同Kubernetes资源的权限。KubernetesRBACAPI定义了四种类型:Role、ClusterRole、RoleBinding与ClusterRoleBinding,这四种类型之间的关系和简要说明如下:Rol......
  • Redis基础篇 - Pub/Sub发布订阅
    文章目录1关于Pub/Sub发布订阅2RedisPub/Sub的基础操作2.1基础操作命令2.2操作示例3使用模式(pattern)订阅3.1使用模式匹配3.2模式匹配的消息格式3.3如果同时匹配了多个呢?4分片Pub/Sub5RedisPub/Sub的一些特性5.1消息传递语义Deliverysemantics5.2推送消......
  • 命令模式在手游后端的应用
    利用命令模式(CommandPattern)在游戏后端架构中实现复杂功能的模块化、解耦以及灵活控制,是一种高级设计技巧。尤其是在手游这种需要处理大量玩家交互、实时数据更新、游戏逻辑复杂且需要高度可扩展性的环境中,命令模式显得尤为重要。下面,我将详细阐述如何在手游后端架构中应用......
  • 方法,命令行传参,方法的可变参数与递归
    方法c中的函数例如 System.out.println() //System是一个类,out是System下的一个(PrintStream类的实例)对象(变量),println是一个方法方法最好保持原子性:一个方法只实现一个功能方法的定义修饰符:可选返回值类型方法名参数类型形参:方法内用的实参:调用方法的语句中的参数......
  • IEC61850教程,第一章:IEC 61850 基础知识介绍
    第一章:IEC61850基础知识介绍平时学习标准或调试IEC61850设备,需要IEC61850模拟器,推荐一款:客户端下载地址:IEC61850客户端模拟器服务端下载地址:IEC61850服务端模拟器什么是IEC61850?IEC61850是定义变电站自动化系统内的设备及其相互作用方式的国际标准。IEC61850的目......
  • 600条最强 Linux 命令总结(珍藏版)
    一、基本命令uname-m显示机器的处理器架构uname-r显示正在使用的内核版本dmidecode-q显示硬件系统部件(SMBIOS/DMI)hdparm-i/dev/hda罗列一个磁盘的架构特性hdparm-tT/dev/sda在磁盘上执行测试性读取操作系统信息arch显示机器的处理器架构uname-m显示机......
  • Redis 基础
    1.初始Redis1.1认识NoSQLNoSql可以翻译做NotOnlySql(不仅仅是SQL),或者是NoSql(非Sql的)数据库。是相对于传统关系型数据库而言,有很大差异的一种特殊的数据库,因此也称之为非关系型数据库。1.1.1结构化与非结构化‍​​1.1.2关系型与非关系型的差异存储方式关系型数据......
  • Redis源码浅析二:命令执行
    1.入口:readQueryFromClient在redis启动的时候,我们还要关注一个重点,在initServer的时候,会执行aeCreateFileEvent,这里我们还有深入学习一下记住这个readQueryFromClient,它是clientrequest到server端处理的入口,有点类似于netty里面的入栈处理器2.readQueryFromClient......