{"id":441549,"date":"2021-04-13T18:42:26","date_gmt":"2021-04-13T10:42:26","guid":{"rendered":"http:\/\/4563.org\/?p=441549"},"modified":"2021-04-13T18:42:26","modified_gmt":"2021-04-13T10:42:26","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-k8s-%e5%af%b9%e5%a4%96%e6%9a%b4%e9%9c%b2-pods-%e7%9a%84%e4%bb%bb%e6%84%8f%e7%ab%af%e5%8f%a3%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=441549","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 k8s \u5bf9\u5916\u66b4\u9732 pods \u7684\u4efb\u610f\u7aef\u53e3\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5982\u4f55\u4f7f\u7528 k8s \u5bf9\u5916\u66b4\u9732 pods \u7684\u4efb\u610f\u7aef\u53e3\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : AkideLiu <\/span>  <span><i><\/i> 1<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5982\u4f55\u4f7f\u7528 k8s \u5728 \u5bf9\u5916\u66b4\u9732 pods \u7684\u4efb\u610f\u7aef\u53e3\uff1f<\/p>\n<p>\u73b0\u5728\u60f3\u5b9e\u73b0\u4f7f\u7528 self host kubernetes \u7684code-server\u8fdb\u884c web preview\uff0c\u73b0\u5728\u7684\u7528\u6cd5\u662f\u4f7f\u7528 yaml \u6587\u4ef6\u91cc\u9762\u5199 services \u548c ingress \u8fdb\u884c\u66b4\u9732\uff0c\u4f46\u662f ports \u662f\u5199\u6b7b\u7684\uff0c\u5982\u679c\u8981\u6253\u5f00\u65b0\u7684\u7aef\u53e3\u5c31\u9700\u8981\u91cd\u65b0\u4fee\u6539 ymal \u3002\u641c\u4e86\u534a\u5929\u4e5f\u6ca1\u627e\u5230\u529e\u6cd5\uff0c\u5e0c\u671b v2 \u7684\u5927\u4f6c\u4eec\u6307\u70b9\u4e00\u4e0b\u3002<\/p>\n<p>example yaml\uff1a<\/p>\n<pre><code>--- apiVersion: networking.k8s.io\/v1beta1 kind: Ingress metadata:   name: code-server-01   namespace: code-server-01   annotations:     kubernetes.io\/ingress.class: nginx spec: # \u5185\u7f51   rules:   - host: code-server-01.xxxxxxx.xip.io     http:       paths:       - backend:           serviceName: code-server-01           servicePort: 80   - host: preview-code-server-01.xxxxxxx.xip.io     http:       paths:       - backend:           serviceName: code-server-01           servicePort: 5500             # \u5916\u7f51   - host: code-01.xxx.com     http:       paths:       - backend:           serviceName: code-server-01           servicePort: 80    - host: preview-code-01.xxx.com     http:       paths:       - backend:           serviceName: code-server-01           servicePort: 5500 --- apiVersion: v1 kind: Service metadata:  name: code-server-01  namespace: code-server-01 spec:  ports:  - port: 80    name: web    targetPort: 8080  - port: 5500    name: preview    targetPort: 5500  selector:    app: code-server-01 <\/code><\/pre>\n<p>\u671f\u671b\u5b9e\u73b0\uff1a<\/p>\n<p>\u6bd4\u5982\u8bf4 gitpod.io \u7684 preview \u5c31\u662f\u6839\u636e\u9700\u6c42\u6253\u5f00\u7aef\u53e3<\/p>\n<p>\u590d\u73b0\u8fc7\u7a0b\uff1a<\/p>\n<ol>\n<li>\u4f7f\u7528 gitpod \u6253\u5f00 express demo http:\/\/gitpod.io\/#\/https:\/\/github.com\/jatins\/express-hello-world<\/li>\n<li>\u4fee\u6539 express default port to 3006<\/li>\n<li>gitpod \u4f1a\u6dfb\u52a0\u4e00\u4e2a\u66b4\u9732 3006<\/li>\n<\/ol>\n<p><img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/04\/20210419_607dc25b30ebf.png\" alt=\"\u5982\u4f55\u4f7f\u7528 k8s \u5bf9\u5916\u66b4\u9732 pods \u7684\u4efb\u610f\u7aef\u53e3\uff1f\" \/><\/p>\n<p>\u6211\u60f3\u8bf7\u6559\u8bf7\u6559\u8fd9\u4e2a\u8fc7\u7a0b\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1f<\/p>\n<p>ps\uff1a\u611f\u89c9\u662f\u4f7f\u7528\u4e86\u4ec0\u4e48\u795e\u5947\u7684 ingress controller\uff0c\u4e0d\u77e5\u9053\u6709\u6ca1\u6709\u5f00\u6e90\u4ea7\u54c1<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5755090\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : kennylam777 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6307\u5b9a\u7684 port: HostPort<br \/>\u4efb\u610f\u7684 port: NodePort<\/p>\n<p>\u770b\u770b ingress \u7684 service yaml \u5c31\u5b78\u6703                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5755091\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : mritd <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u662f\u5f00\u53d1\u73af\u5883\u53ef\u4ee5\u5b8c\u5168\u5c06\u7f51\u7edc\u6253\u901a\uff0cCNI flannel(\u88f8\u673a host-gw)\uff0c\u7136\u540e\u4e0a\u7ea7\u8def\u7531 \u628a pod CIDR \u629b\u4efb\u610f\u4e00\u53f0\u4e3b\u673a\u5373\u53ef\uff0c\u8fd9\u6837\u5728\u5916\u90e8\u5c31\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee pod ip \u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5755092\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jorneyr <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u4eec\u662f\u4f7f\u7528\u7f51\u7edc\u63d2\u4ef6\uff0c\u4f7f\u5f97 Pod IP \u53ef\u4ee5\u5916\u7f51\u8bbf\u95ee\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5755093\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jk1030 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             NodePort \u4e0d\u884c\u561b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528 k8s \u5bf9\u5916\u66b4\u9732 pod&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\/441549"}],"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=441549"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/441549\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=441549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=441549"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=441549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}