使用 minikube 创建服务
Creating service using a minikube
尝试 运行 minikube 中带有 nginx 镜像的简单服务
我运行使用以下命令进行了部署和服务
felipeflores@GMEPN004052:~$ kubectl run meu-nginx --image nginx --port 80
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
deployment.apps/meu-nginx created
felipeflores@GMEPN004052:~$ kubectl expose deployment meu-nginx
service/meu-nginx exposed
已正确创建我的服务,但我无法使用端口
访问端点
felipeflores@GMEPN004052:~$ kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 55d
meu-nginx ClusterIP 10.108.164.133 <none> 80/TCP 20m
但是
felipeflores@GMEPN004052:~$ curl 10.108.164.133
curl: (7) Failed to connect to 10.108.164.133 port 80
有关我提供的描述服务和部署的信息
felipeflores@GMEPN004052:~$ kubectl describe service meu-nginx
Name: meu-nginx
Namespace: default
Labels: run=meu-nginx
Annotations: <none>
Selector: run=meu-nginx
Type: ClusterIP
IP: 10.108.164.133
Port: <unset> 80/TCP
TargetPort: 80/TCP
Endpoints: 172.17.0.15:80
Session Affinity: None
Events: <none>
felipeflores@GMEPN004052:~$ kubectl describe deploy meu-nginx
Name: meu-nginx
Namespace: default
CreationTimestamp: Mon, 29 Apr 2019 09:07:46 -0300
Labels: run=meu-nginx
Annotations: deployment.kubernetes.io/revision: 1
Selector: run=meu-nginx
Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: run=meu-nginx
Containers:
meu-nginx:
Image: nginx
Port: 80/TCP
Host Port: 0/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
OldReplicaSets: <none>
NewReplicaSet: meu-nginx-546db5bbc9 (1/1 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 27m deployment-controller Scaled up replica set meu-nginx-546db5bbc9 to 1
ClusterIP 类型的服务不可从 Kubernetes 外部使用。您需要使用服务类型 LoadBalancer 或 NodePort。
请阅读:
https://kubernetes.io/docs/tutorials/hello-minikube/#create-a-service
https://medium.com/@xcoulon/deploying-your-first-web-app-on-minikube-6e98d2884b3a
尝试 运行 minikube 中带有 nginx 镜像的简单服务
我运行使用以下命令进行了部署和服务
felipeflores@GMEPN004052:~$ kubectl run meu-nginx --image nginx --port 80
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
deployment.apps/meu-nginx created
felipeflores@GMEPN004052:~$ kubectl expose deployment meu-nginx
service/meu-nginx exposed
已正确创建我的服务,但我无法使用端口
访问端点felipeflores@GMEPN004052:~$ kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 55d
meu-nginx ClusterIP 10.108.164.133 <none> 80/TCP 20m
但是
felipeflores@GMEPN004052:~$ curl 10.108.164.133
curl: (7) Failed to connect to 10.108.164.133 port 80
有关我提供的描述服务和部署的信息
felipeflores@GMEPN004052:~$ kubectl describe service meu-nginx
Name: meu-nginx
Namespace: default
Labels: run=meu-nginx
Annotations: <none>
Selector: run=meu-nginx
Type: ClusterIP
IP: 10.108.164.133
Port: <unset> 80/TCP
TargetPort: 80/TCP
Endpoints: 172.17.0.15:80
Session Affinity: None
Events: <none>
felipeflores@GMEPN004052:~$ kubectl describe deploy meu-nginx
Name: meu-nginx
Namespace: default
CreationTimestamp: Mon, 29 Apr 2019 09:07:46 -0300
Labels: run=meu-nginx
Annotations: deployment.kubernetes.io/revision: 1
Selector: run=meu-nginx
Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: run=meu-nginx
Containers:
meu-nginx:
Image: nginx
Port: 80/TCP
Host Port: 0/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
OldReplicaSets: <none>
NewReplicaSet: meu-nginx-546db5bbc9 (1/1 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 27m deployment-controller Scaled up replica set meu-nginx-546db5bbc9 to 1
ClusterIP 类型的服务不可从 Kubernetes 外部使用。您需要使用服务类型 LoadBalancer 或 NodePort。
请阅读:
https://kubernetes.io/docs/tutorials/hello-minikube/#create-a-service https://medium.com/@xcoulon/deploying-your-first-web-app-on-minikube-6e98d2884b3a