20220806实习进度汇报

实习进度汇报

这几天在做什么:

  • hugo 更新实习日记至github主页上
  • git代码管理 上传demo方便导师检查
  • 以deployment和service方式部署应用
  • client-go的学习

这些事情的进度:

1.使用hugo更新实习日记至github主页

github主页 (linjianshu.github.io)

https://github.com/linjianshu/e-book-Gin

https://github.com/linjianshu/client-go

3.以deployment和service方式部署应用
  • 运行截图

  • deployment.yaml文件 web应用

apiVersion: apps/v1
kind: Deployment
metadata:
  name: e-book-gin
  labels:
    app: e-book-gin
    version: v1.0.0
spec:
  replicas: 2
  selector:
    matchLabels:
      app: e-book-gin
      version: v1.0.0
  strategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: e-book-gin
        version: v1.0.0
    spec:
      containers:
        - image: ccr.ccs.tencentyun.com/hfut-ie/e-book-gin:v3.0 #镜像
          name: e-book-gin
          ports:
            - containerPort: 7777
              name: e-book-gin
  • service.yaml文件
apiVersion: v1
kind: Service
metadata:
#  服务名字
  name: test-service
spec:
  selector:
#    对应pod的标签
    app: e-book-gin
#    默认 ClusterIP 集群内可访问 NodePort节点可访问 LoadBalancer 负载均衡模式 (需要负载均衡器才可用)
  type: NodePort
  ports:
    - port: 8080  #本 service端口
      targetPort: 7777 #容器端口
      nodePort: 31000 #节点端口 范围固定 从30000-32767
  • 运行截图

deployment

image-20220806104916704
image-20220806104916704

pod

image-20220806104857355
image-20220806104857355

service

image-20220806104827062
image-20220806104827062

image-20220806105306455
image-20220806105306455

NodePort类型 需要节点nodePort: 31000访问 进入节点 curl验证

image-20220806105510785
image-20220806105510785

5.client-go的学习
  • rest-client获取pods信息

image-20220809151945441
image-20220809151945441

  • client-set获取pods信息

image-20220809152042518
image-20220809152042518

  • dynamic-client获取pods信息

image-20220809152118760
image-20220809152118760

  • discover-client发现GVR资源

image-20220809152231368
image-20220809152231368

  • watch demo

image-20220809162701324
image-20220809162701324

存在哪些问题:

  • client-go可以从k8s宿主机之外访问吗 使用自己电脑尝试连接腾讯云显示网络无法访问 ping ip没ping通 是需要额外做一些操作让网络先联通起来吗?

image-20220809152608948
image-20220809152608948

打算接下来做什么:

  1. 掌握 statefulset、deployment 用法,实现2副本高可用并将两个pod调度至不同node(反亲和);
  2. 学习 secret、configmap 用法并应用;
  3. client-go 实现demo(创建deployment编排之前的docker镜像并运行);
kubectl常用指令

kubectl get node

kubectl run testapp –image=ccr.ccs.tencentyun.com/hfut/e-book-gin:v1.0

kubectl apply -f ./mysql.yaml

kubectl get pod

kubectl get deployment

kubectl get pod -o wide

kubectl describe pod [testapp]

kubectl logs testapp –previous

kubectl delete pod my-mysql-6b8cf957fc-2sl59

kubectl delete deploy/my-mysql

伸缩副本 kubectl scale deployment test-k8s –replicas=2

查看历史版本 kubectl rollout history deployment [deployment]

回到上个版本 kubectl rollout undo deployment [deployment]

回退指定版本 kubectl rollout undo deployment test-k8s –to-revision=2 删除部署 kubectl delete deployment test-k8s

查看所有信息 kubectl get all

重新部署 kubectl rullout restart deployment test-k8s

命令修改镜像

kubectl set image deployment test-k8s test-k8s=ccr.ccs.tencentyun.com/k8s-tutorial/test-k8s:v2-with-error –record

暂停运行 去做想做的事情 比如修改其他的pod之类的 kubectl rollout pause deployment my-mysql

恢复 kubectl rollout resume deployment my-mysql

输出到文件 kubectl get deployment my-mysql -o yaml » toyaml.yaml

kubectl delete all –all

kubectl get service

kubectl get svc

kubectl api-versions

kubectl api-resources

Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy