在AWS EC2上部署Kubernetes服务时无法连接网页

时间:2020-04-11 05:33:55

标签: kubernetes ansible devops kubernetes-pod

即使Kubernete已成功在AWS EC2上部署服务,我也无法访问该网页,并且我可以检查它是否正在运行,并且

Web浏览器链接:EC2公共IP(并且我已经尝试从kubectl获取服务的私有IP和外部ip):8080(也已经尝试了31200)

结果:

Unable to connect

我也尝试执行以下命令,但结果是连接失败`被拒绝。

wget 127.0.0.1:8080 and wget 127.0.0.1:31200

打开了8080和31200的防火墙规则。

我正在通过以下命令通过AWS EC2上的kubernetes部署和服务来部署Web应用程序

ansible-playbook -i /opt/kubernetes/hosts /opt/kubernetes/website-deployment.yml;
ansible-playbook -i /opt/kubernetes/hosts /opt/kubernetes/website-service.yml;

deployment.yml是

---
- name: Create pods using deployment 
  hosts: localhost
  become: true
  user: root

  tasks: 
  - name: create a deployment
    command: kubectl apply -f /opt/docker/website-deployment.yml

  - name: update deployment with new pods whenever image updated in docker hub
    command: kubectl rollout restart deployment.v1.apps/website-deployment

服务yml是

---
- name: create service for deployment
  hosts: localhost
  become: true
  user: root

  tasks:
  - name: create a service
    command: kubectl apply -f /opt/docker/website-service.yml

我跑步时

kubectl get services

NAME              TYPE           CLUSTER-IP       EXTERNAL-IP                                                               PORT(S)          AGE
web-service   LoadBalancer   100.64.119.242   afefc1ecf599f4a16a12aa2fe5dbbb30-614667794.ap-south-1.elb.amazonaws.com   8080:***31200***/TCP   12h
kubernetes        ClusterIP      100.64.0.1       <none>                                                                    443/TCP          36h

kubectl get pods
NAME                                  READY   STATUS    RESTARTS   AGE
web-service-deployment-7df8c9bc7c-g9hkp   1/1     Running   0          135m
web-service-deployment-7df8c9bc7c-pmtlv   1/1     Running   0          135m
sample-nginx                          1/1     Running   0          38h

0 个答案:

没有答案