简体   繁体   English

访问部署在 Kubernetes 上的应用程序

[英]Access application deployed on Kubernetes

I have my image hosted on GCR.我的图片托管在 GCR 上。 I deployed my application on local Kubernetes cluster(mac).我在本地 Kubernetes 集群(mac)上部署了我的应用程序。 This is my deployment file -这是我的部署文件 -

apiVersion: apps/v1
kind: Deployment
metadata:
  name: sv-premier
spec:
  selector:
    matchLabels:
      app: sv-premier
  template:
    metadata:
      labels:
        app: sv-premier
    spec:
      volumes:
      - name: google-cloud-key
        secret:
          secretName: gcp-key
      containers:
      - name: sv-premier
        image: gcr.io/proto/premiercore1:latest
        imagePullPolicy: Always
        command: ["echo", "Done deploying sv-premier"]
        volumeMounts:
        - name: google-cloud-key
          mountPath: /var/secrets/google
        env:
        - name: GOOGLE_APPLICATION_CREDENTIALS
          value: /var/secrets/google/key.json
        ports:
        - containerPort: 8080
      imagePullSecrets:
      - name: imagepullsecretkey

I am trying to access the application but I am not able to.我正在尝试访问该应用程序,但无法访问。 I created the service as -->我将服务创建为 -->

$ kubectl expose deployment sv-premier --port=8080 --target-port=8080
service/sv-premierleague exposed

$ kubectl get service sv-premier
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
sv-premier   ClusterIP   10.107.202.156   <none>        8080/TCP   58s

$ kubectl get all -o wide $ kubectl get all -o wide

NAME                              READY   STATUS    RESTARTS   AGE   IP          NODE             NOMINATED NODE   READINESS GATES
pod/sv-premier-6b695d5fd7-l4995   1/1     Running   0          21h   10.1.0.45   docker-desktop   <none>           <none

NAME                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE   SELECTOR
service/kubernetes   ClusterIP   10.96.0.1        <none>        443/TCP    8d    <none>
service/sv-premier   ClusterIP   10.107.202.156   <none>        8080/TCP   23m   app=sv-premier

NAME                         READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS   IMAGES                                    SELECTOR
deployment.apps/sv-premier   1/1     1            1           21h   sv-premier   gcr.io/sap-s4-proto/premiercore1:latest   app=sv-premier


NAME                                    DESIRED   CURRENT   READY   AGE   CONTAINERS   IMAGES                                    SELECTOR
replicaset.apps/sv-premier-6b695d5fd7   1         1         1       21h   sv-premier   gcr.io/sap-s4-proto/premiercore1:latest   app=sv-premierleague,pod-template-hash=6b695d5fd7

$ kubectl get nodes -o wide $ kubectl get nodes -o wide

NAME             STATUS   ROLES    AGE   VERSION   INTERNAL-IP    EXTERNAL-IP   OS-IMAGE         KERNEL-VERSION     CONTAINER-RUNTIME
docker-desktop   Ready    master   8d    v1.15.5   192.168.65.3   <none>        Docker Desktop   4.19.76-linuxkit   docker://19.3.5

Now as mentioned here in the accepted answer, I am trying to access my application like -- docker-desktop:NodePort ie 192.168.65.3:8080.现在,当提到这里的接受的答案,我想访问喜欢我的应用程序-泊坞窗-桌面:NodePort即192.168.65.3:8080。 But I am not able to.但我不能。 在此处输入图片说明

Update your command to include the type to expose service on nodeport更新您的命令以包含在 nodeport 上公开服务的类型

kubectl expose deployment sv-premier --port=8080 --type=NodePort

Then your should try to reach the service using .. ip:nodeport combination然后您应该尝试使用 .. ip:nodeport 组合访问该服务

Are you using Google cloud ?你在使用谷歌云吗? The you should prefer service type=loadbalancer您应该更喜欢 service type=loadbalancer

When you create a Service of type LoadBalancer, a Google Cloud controller auto configures a network load balancer.当您创建 LoadBalancer 类型的服务时,Google Cloud 控制器会自动配置网络负载平衡器。 Wait a minute for the controller to configure the network load balancer and generate a stable IP address.稍等片刻,让控制器配置网络负载均衡器并生成稳定的 IP 地址。 Use details from the loadbalncer to access the service.使用负载均衡器中的详细信息来访问该服务。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用kubernetes游乐场访问部署在kubernetes集群上的应用程序 - unable to access the application deployed on kubernetes cluster using kubernetes playground https Kubernetes 部署的应用程序 - https kubernetes deployed application 在Azure Kubernetes服务(AKS)上部署的Web应用程序的访问日志生成 - Access Log generation of deployed web application on Azure Kubernetes Service (AKS) 在VirtualBox中的多集复制kubernetes环境中访问已部署的应用程序时遇到问题 - Having problem to access deployed application in multiclustering kubernetes environment in VirtualBox 如何设置 k8s 访问部署在 Kubernetes 上的 tomcat 中运行的应用程序? - How set k8s to access the application running in tomcat deployed on Kubernetes? 无法使用Azure CICD管道访问部署在Azure ACS Kubernetes群集中的应用程序 - Cannot access application deployed in Azure ACS Kubernetes Cluster using Azure CICD Pipeline 为什么我可以通过 minikube 中的 ClusterIP 访问我的 Kubernetes 部署应用程序? - Why I can access my Kubernetes deployed application through it's ClusterIP in minikube? 当应用程序部署在 Kubernetes 或 Linux 中时,如何从 Kotlin 读取/访问/访问文件 - how read/reach/access a file from Kotlin when the application is deployed either in Kubernetes or Linux 如何访问部署在 Kubernetes 集群上的 postgresql - How to access postgresql, deployed on Kubernetes cluster 无法访问部署在 Kubernetes 系统上的应用程序 UI - Unable to reach the Application UI deployed on a Kubernetes system
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM