wget https://get.helm.sh/helm-v3.9.0-linux-amd64.tar.gz tar xvf helm-v3.9.0-linux-amd64.tar.gz mv linux-amd64/helm /usr/local/bin/ helm repo add hybridnet https://alibaba.github.io/hybridnet/ helm repo update helm install hybridnet hybridnet/hybridnet -n kube-system --set init.cidr=10.244.0.0/16 kubectl get node -owide kubectl get pod -A kubectl get pod -A -owide #安装k8s master快捷键 yum install bash-completion -y source /usr/share/bash-completion/bash_completion source <(kubectl completion bash) echo "source <(kubectl completion bash)" >> ~/.bashrc kubectl get pod -A -owide #显示所有容器 kubectl label node k8s1-srv-node1-test network=underlay-nethost #给k8s 打标签 kubectl label node k8s1-srv-node2-test network=underlay-nethost kubectl label node k8s1-srv-node3-test network=underlay-nethost kubectl label node k8s1-srv-node4-test network=underlay-nethost vim 1.create-underlay-network.yaml #创建网络 apiVersion: networking.alibaba.com/v1 kind: Network metadata: name: underlay-network1 spec: netID: 0 type: Underlay nodeSelector: network: "underlay-nethost" --- apiVersion: networking.alibaba.com/v1 kind: Subnet metadata: name: underlay-network1 spec: network: underlay-network1 netID: 0 range: version: "4" cidr: "192.168.247.0/24" gateway: "192.168.247.2" # 外部网关地址 start: "192.168.247.10" end: "192.168.247.254" kubectl apply -f 1.create-underlay-network.yaml [root@k8s1-srv-master1-test data]# kubectl get network NAME NETID TYPE MODE V4TOTAL V4USED V4AVAILABLE LASTALLOCATEDV4SUBNET V6TOTAL V6USED V6AVAILABLE LASTALLOCATEDV6SUBNET init 4 Overlay 65534 4 65530 init 0 0 0 underlay-network1 0 Underlay 972 1 971 underlay-network1 0 0 0 kubectl create ns myserver vi 3.tomcat-app1-underlay.yaml kind: Deployment #apiVersion: extensions/v1beta1 apiVersion: apps/v1 metadata: labels: app: myserver-tomcat-app1-deployment-underlay-label name: myserver-tomcat-app1-deployment-underlay namespace: myserver spec: replicas: 1 selector: matchLabels: app: myserver-tomcat-app1-underlay-selector template: metadata: labels: app: myserver-tomcat-app1-underlay-selector annotations: #使用Underlay或者Overlay网络 networking.alibaba.com/network-type: Underlay spec: #nodeName: k8s-node2.example.com containers: - name: myserver-tomcat-app1-container #image: tomcat:7.0.93-alpine image: registry.cn-hangzhou.aliyuncs.com/zhangshijie/tomcat-app1:v2 imagePullPolicy: IfNotPresent ##imagePullPolicy: Always ports: - containerPort: 8080 protocol: TCP name: http env: - name: "password" value: "123456" - name: "age" value: "18" # resources: # limits: # cpu: 0.5 # memory: "512Mi" # requests: # cpu: 0.5 # memory: "512Mi" --- kind: Service apiVersion: v1 metadata: labels: app: myserver-tomcat-app1-service-underlay-label name: myserver-tomcat-app1-service-underlay namespace: myserver spec: # type: NodePort ports: - name: http port: 80 protocol: TCP targetPort: 8080 #nodePort: 40003 selector: app: myserver-tomcat-app1-underlay-selector kubectl apply -f 3.tomcat-app1-underlay.yaml kubectl -n myserver get pod -owide kubectl -n myserver describe pod myserver-tomcat-app1-deployment-underlay-65c6f47db4-qfwwh kubectl get node --show-labels 查看打得标签 kubectl -n myserver get pod -owide #查看pod 信息 kubectl -n myserver describe pod myserver-tomcat-app1-deployment-underlay-65c6f47db4-f6fkq kubectl -n myserver get pod -owide vi 3.tomcat-app1-underlay.yaml kubectl -n myserver exec -it myserver-tomcat-app1-deployment-underlay-65c6f47db4-f6fkq /bin/sh kubectl -n myserver get pod -owide
标签:kubectl,tomcat,get,网络,app1,myserver,k8s,underlay From: https://www.cnblogs.com/quemengqio/p/17092083.html