【发布时间】:2021-05-23 02:56:18
【问题描述】:
我是 kubernetes 的新手,正在尝试部署一个简单的 hello-world 应用程序。我正在使用 Ubuntu 20.04 并在 VMware 工作站上运行它。我已经安装了 minikube 并尝试部署。但是,已部署 pod,但无法通过浏览器访问服务。
下面是我的deployment.yaml文件:
---
kind: Service
apiVersion: v1
metadata:
name: exampleservice
spec:
selector:
name: myapp
ports:
- protocol: "TCP"
# Port accessible inside cluster
port: 8081
# Port to forward to inside the pod
targetPort: 8080
# Port accessible outside cluster
nodePort: 30000
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: myappdeployment
spec:
replicas: 5
selector:
matchLabels:
name: myapp
template:
metadata:
labels:
name: myapp
spec:
containers:
- name: myapp
image: pritishkapli/example:v1.0.0
ports:
- containerPort: 8080
resources:
limits:
memory: 512Mi
cpu: "1"
requests:
memory: 256Mi
cpu: "0.2"
下面是kubernetes服务:
pritish@ubuntu:~$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
exampleservice LoadBalancer 10.101.149.155 <pending> 8081:30000/TCP 12m
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 9h
下面是正在运行的 pod:
pritish@ubuntu:~$ kubectl get pods
NAME READY STATUS RESTARTS AGE
myappdeployment-b85b56d64-knhhc 1/1 Running 0 17m
myappdeployment-b85b56d64-m4vbg 1/1 Running 0 17m
myappdeployment-b85b56d64-qss4l 1/1 Running 0 17m
myappdeployment-b85b56d64-r2jq4 1/1 Running 0 17m
myappdeployment-b85b56d64-tflnz 1/1 Running 0 17m
请帮忙!
PS:我已经更新了deployment.yaml 文件,它按预期工作。
【问题讨论】:
-
这能回答你的问题吗? Kubernetes service external ip pending
标签: kubernetes yaml minikube