{"id":85248,"date":"2020-03-31T21:21:16","date_gmt":"2020-03-31T13:21:16","guid":{"rendered":"http:\/\/4563.org\/?p=85248"},"modified":"2020-03-31T21:21:16","modified_gmt":"2020-03-31T13:21:16","slug":"kubernetes-%e5%ae%b9%e5%99%a8%e4%b9%8b%e9%97%b4%e6%80%8e%e4%b9%88%e8%bf%9b%e8%a1%8c%e7%bd%91%e7%bb%9c%e9%80%9a%e4%bf%a1","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=85248","title":{"rendered":"kubernetes \u5bb9\u5668\u4e4b\u95f4\u600e\u4e48\u8fdb\u884c\u7f51\u7edc\u901a\u4fe1"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  kubernetes \u5bb9\u5668\u4e4b\u95f4\u600e\u4e48\u8fdb\u884c\u7f51\u7edc\u901a\u4fe1               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fangwenxue <\/span>  <span><i><\/i> 9<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<pre><code>try:     _redis_client = Redis('redis')     print(_redis_client.info()) except Exception as e:     print(e) <\/code><\/pre>\n<ul>\n<li>docker yml<\/li>\n<\/ul>\n<pre><code>version: \"3\" services:   web:     build: .     ports:       - \"8080:8080\"     restart: always    redis:     image: redis:5-alpine     ports:       - \"6379:6379\"     volumes:       - \"\/data\"     restart: always <\/code><\/pre>\n<ul>\n<li>k8s.yml<\/li>\n<\/ul>\n<pre><code>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 <\/code><\/pre>\n<ul>\n<li>docker yml \u53ef\u4ee5\u8fde\u4e0a redis<\/li>\n<li>k8s yml \u8fde\u4e0d\u4e0a redis<\/li>\n<\/ul>\n<p>\u600e\u4e48\u8fde\u4e0a k8s \u7684 redis<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1409992\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qoo2019 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6700\u7b80\u5355\u7684 nodeport \u6620\u5c04\u4e2a\u7aef\u53e3                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1409993\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zeron889 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u4e2a\u6709\u4e24\u79cd\u65b9\u5f0f\uff0c\u4e00\u4e2a\u662f\u8d70 cluster ip \u7684 svc\uff0c\u548c\u8d70 nodeport \u7684\u4e3b\u673a\u66b4\u9732\u7aef\u53e3                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1409994\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : julyclyde <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd0\u884c docker \u7684\u65f6\u5019\u522b\u7528 NAT \u6a21\u5f0f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>kubernetes \u5bb9\u5668\u4e4b\u95f4\u600e\u4e48&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/85248"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=85248"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/85248\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=85248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=85248"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=85248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}