码迷,mamicode.com
首页 > 其他好文 > 详细

k8s使用心得

时间:2020-07-30 14:44:47      阅读:85      评论:0      收藏:0      [点我收藏+]

标签:stat   not   des   eve   config   count   dom   SHA256   err   

查看当前所有namespaces

[root@master ~]# kubectl get namespaces -A
NAME              STATUS   AGE
default           Active   63d
hkd               Active   31d
kube-node-lease   Active   57d
kube-public       Active   63d
kube-system       Active   63d
nginx-ingress     Active   30d
test              Active   30d

查看指定namespaces 下的ingress

[root@master ~]# kubectl get ingress --namespace=test
NAME           CLASS    HOSTS                               ADDRESS   PORTS   AGE
cloud-eureka   <none>   cloud-eureka.test.demo.kuboard.cn             80      26d

查看ingress详情

[root@master ~]# kubectl describe ingress --namespace=test   
Name:             cloud-eureka
Namespace:        test
Address:          
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
  Host                               Path  Backends
  ----                               ----  --------
  cloud-eureka.test.demo.kuboard.cn  
                                     /   cloud-eureka:sntdnc (10.100.171.66:8761)
Annotations:                         k8s.kuboard.cn/displayName: eureka注册中心
                                     k8s.kuboard.cn/workload: cloud-eureka
Events:                              <none>

从ingress详情中可以看到,ingress下面的service名称是cloud-eureka,目前该service下只有一个pod:10.100.171.66:8761

查看service

[root@master ~]# kubectl get service --namespace=test
NAME           TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
cloud-config   NodePort   10.96.249.98   <none>        8888:32155/TCP   21d
cloud-eureka   NodePort   10.96.181.80   <none>        8761:31739/TCP   27d

service详情

[root@master ~]# kubectl describe service cloud-eureka --namespace=test
Name:                     cloud-eureka
Namespace:                test
Labels:                   k8s.kuboard.cn/layer=cloud
                          k8s.kuboard.cn/name=cloud-eureka
Annotations:              k8s.kuboard.cn/displayName: eureka注册中心
                          k8s.kuboard.cn/workload: cloud-eureka
Selector:                 k8s.kuboard.cn/layer=cloud,k8s.kuboard.cn/name=cloud-eureka
Type:                     NodePort
IP:                       10.96.181.80
Port:                     sntdnc  8761/TCP
TargetPort:               8761/TCP
NodePort:                 sntdnc  31739/TCP
Endpoints:                10.100.171.66:8761
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

查看pod

[root@master ~]# kubectl get pods --namespace=test
NAME             READY   STATUS    RESTARTS   AGE
cloud-config-0   1/1     Running   5          21d
cloud-eureka-0   1/1     Running   3          21d

pod详情

[root@master ~]# kubectl describe pods cloud-eureka-0 --namespace=test
Name:         cloud-eureka-0
Namespace:    test
Priority:     0
Node:         worker/192.168.75.11
Start Time:   Thu, 09 Jul 2020 09:12:57 +0800
Labels:       controller-revision-hash=cloud-eureka-7f95b587f
              k8s.kuboard.cn/layer=cloud
              k8s.kuboard.cn/name=cloud-eureka
              statefulset.kubernetes.io/pod-name=cloud-eureka-0
Annotations:  cni.projectcalico.org/podIP: 10.100.171.66/32
              cni.projectcalico.org/podIPs: 10.100.171.66/32
Status:       Running
IP:           10.100.171.66
IPs:
  IP:           10.100.171.66
Controlled By:  StatefulSet/cloud-eureka
Containers:
  hkd-eureka:
    Container ID:   docker://5df85e2f1769341b9903ef060405780cb3fe5a0037e23177f64f54e616598bcc
    Image:          idocker.io/hkd-eureka:0.5
    Image ID:       docker-pullable://idocker.io/hkd-eureka@sha256:0057434b09b824a76fdd7006c107c3d295f26c300080b305a9cad455750450c8
    Port:           <none>
    Host Port:      <none>
    State:          Running
      Started:      Thu, 30 Jul 2020 09:55:41 +0800
    Last State:     Terminated
      Reason:       Error
      Exit Code:    143
      Started:      Thu, 30 Jul 2020 09:55:25 +0800
      Finished:     Thu, 30 Jul 2020 09:55:26 +0800
    Ready:          True
    Restart Count:  3
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-7tr62 (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  default-token-7tr62:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-7tr62
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:          <none>

从pod详情中可以看到该pod所在node主机,里面的容器等信息

进入pod里的容器中

[root@master ~]# kubectl exec -it cloud-eureka-0 --namespace=test -- /bin/sh
/ # date
Thu Jul 30 12:11:20 CST 2020
/ # ps -ef
PID   USER     TIME  COMMAND
    1 root      2:35 java -Djava.security.egd=file:/dev/./urandom -jar /hkd-eureka-1.0.jar
  101 root      0:00 /bin/sh
  118 root      0:00 /bin/sh
  125 root      0:00 ps -ef
/ # 

临时执行pod容器中的命令

[root@master ~]# kubectl exec  cloud-eureka-0 --namespace=test -- date
Thu Jul 30 13:48:41 CST 2020

k8s使用心得

标签:stat   not   des   eve   config   count   dom   SHA256   err   

原文地址:https://www.cnblogs.com/sanduzxcvbnm/p/13403044.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!