[英]Kubernetes: access from outside
I have a flask app running on a remote Kubernetes cluster and when I'm accessing it on the inside it works.我有一个 flask 应用程序在远程 Kubernetes 集群上运行,当我在内部访问它时它可以工作。 However, when I'm trying to access it from the outside nothing happens.
但是,当我尝试从外部访问它时,什么也没有发生。 I'm using kind to create the cluster.
我正在使用 kind 来创建集群。 Locally I can access the flask app via node's IP address.
在本地,我可以通过节点的 IP 地址访问 flask 应用程序。 I'm don't know how to access the service from the outside, do I need to do something else to be able to access the app.
我不知道如何从外部访问该服务,是否需要执行其他操作才能访问该应用程序。
apiVersion: v1
vi serkind: Service
metadata:
name: iweblens-svc
labels:
app: flaskapp
spec:
type: NodePort
ports:
- port: 5000
targetPort: 5000
protocol: TCP
selector:
app: flaskapp
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
kubeadmConfigPatches:
- |
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
evictionHard:
nodefs.available: "0%"
kubeadmConfigPatchesJSON6902:
- group: kubeadm.k8s.io
version: v1beta2
kind: ClusterConfiguration
patch: |
- op: add
path: /apiServer/certSANs/-
value: my-hostname
nodes:
- role: control-plane
- role: worker
apiVersion: apps/v1
kind: Deployment
metadata:
name: flaskapp
labels:
app: flaskapp
spec:
replicas: 1
selector:
matchLabels:
app: flaskapp
template:
metadata:
labels:
app: flaskapp
spec:
containers:
- name: flaskapp
image: myimage
imagePullPolicy: Never
ports:
- containerPort: 5000
resources:
limits:
cpu: "0.5"
requests:
cpu: "0.5"
Create a NodePort or LoadBalancer (works only on supported cloud providers) service to expose the deployment outside the cluster.创建 NodePort 或 LoadBalancer(仅适用于受支持的云提供商) 服务以在集群外公开部署。
Here is a guide on how to use NodePort service.这里是如何使用 NodePort 服务的指南。
To be be able to access an app via NodePort service the Node IP need to be reachable(ie should be in same network) from the system where you are accessing it.为了能够通过 NodePort 服务访问应用程序,节点 IP 需要可从您访问它的系统访问(即应该在同一网络中)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.