跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • kubernetes 容器之间怎么进行网络通信
未分類
31 3 月 2020

kubernetes 容器之间怎么进行网络通信

kubernetes 容器之间怎么进行网络通信

資深大佬 : fangwenxue 9

try:     _redis_client = Redis('redis')     print(_redis_client.info()) except Exception as e:     print(e) 
  • docker yml
version: "3" services:   web:     build: .     ports:       - "8080:8080"     restart: always    redis:     image: redis:5-alpine     ports:       - "6379:6379"     volumes:       - "/data"     restart: always 
  • k8s.yml
apiVersion: apps/v1 kind: Deployment metadata:   name: pytest spec:   replicas: 1   template:     metadata:       labels:         app: pytest     spec:       containers:         - name: web           image: '..'           ports:             - containerPort: 8080  ---  apiVersion: apps/v1 kind: Deployment metadata:   name: redis spec:     spec:       volumes:         - name: redis-data       containers:         - name: redis           image: redis:5-alpine           ports:             - containerPort: 6379               protocol: TCP           volumeMounts:             - name: redis-data               mountPath: /data   selector:     matchLabels:       app: redis   ---  apiVersion: v1 kind: Service metadata:   name: web spec:   type: NodePort   ports:   - name: "web"     port: 8080   selector:     app: pytest  --- apiVersion: v1 kind: Service metadata:   name: redis spec:   type: NodePort   ports:   - name: "redis"     port: 6379   selector:     app: redis 
  • docker yml 可以连上 redis
  • k8s yml 连不上 redis

怎么连上 k8s 的 redis

大佬有話說 (3)

  • 資深大佬 : qoo2019

    最简单的 nodeport 映射个端口

  • 資深大佬 : zeron889

    这个有两种方式,一个是走 cluster ip 的 svc,和走 nodeport 的主机暴露端口

  • 資深大佬 : julyclyde

    运行 docker 的时候别用 NAT 模式

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具