EKS负载均衡器无法访问

时间:2019-11-07 00:34:10

标签: docker kubernetes gatsby aws-eks

我有一个gatsby应用程序,并且正在使用EKS来管理我的集群。尽管将其摆到我的吊舱中并against缩在using System; using System.Collections.Generic; using System.Net; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; namespace GetData { public class ReceiptHeader { private string _company; private string _warehouse; public ReceiptHeader() { } public string Company { get { return _company; } set { _company = value; } } public string Warehouse { get { return _warehouse; } set { _warehouse = value; } } } class Program { static HttpClient client = new HttpClient(); static void ShowHeader(ReceiptHeader crh) { Console.WriteLine($"Company: {crh.Company}\tWarehouse: " + $"{crh.Warehouse}"); } static async Task<ReceiptHeader> GetRHAsync(string path) { ReceiptHeader HeaderInfo = null; HttpResponseMessage response = await client.GetAsync(path); if (response.IsSuccessStatusCode) { HeaderInfo = await response.Content.ReadAsAsync<ReceiptHeader>(); } return HeaderInfo; } static void Main() { RunAsync().GetAwaiter().GetResult(); } static async Task RunAsync() { // Update port # in the following line. client.BaseAddress = new Uri("https://externalwebaddress.com/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "TOKEN"); try { // Get the header crh = await GetRHAsync(url.PathAndQuery); ShowHeader(crh); } catch (Exception e) { Console.WriteLine(e.Message); } Console.ReadLine(); } } } 上并收到了响应,但我还是无法击中负载平衡器并获得响应。

这是我的Dockerfile的样子

localhost:3000

这是我的k8s文件的样子

FROM node:10

WORKDIR /app

COPY package.json ./

RUN yarn

COPY . .

RUN yarn gatsby:build-staging




EXPOSE 3000

ENV NODE_ENV=development
ENV REACT_APP_STAGE=development


CMD [ "yarn", "serve" ]

这是apiVersion: v1 kind: Service metadata: name: <SOME_NAME> labels: app: <SOME_NAME> annotations: # Note that the backend talks over HTTP. service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http # TODO: Not comfortable with this being in code - TODO: move this into a circleci environment variable service.beta.kubernetes.io/aws-load-balancer-ssl-cert: <SSL CERT> # Only run SSL on the port named "https" below. service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "https" spec: type: LoadBalancer selector: app: <SOME_NAME> ports: - port: 443 targetPort: 3000 protocol: TCP name: https - port: 80 targetPort: 3000 protocol: TCP name: http --- apiVersion: apps/v1 kind: Deployment metadata: name: <SOME_NAME> labels: app: <SOME_NAME> spec: replicas: 1 selector: matchLabels: app: <SOME_NAME> template: metadata: labels: app: <SOME_NAME> spec: containers: - name: <SOME_NAME> image: <IMAGE_NAME> imagePullPolicy: Always env: - name: VERSION_INFO value: "1.0" - name: BUILD_DATE value: "1.0" ports: - containerPort: 3000 的样子

serve

我不明白为什么会有问题-当我缩进吊舱并curl着"gatsby serve -p 3000" 时,我得到了回应。负载均衡器似乎出了点问题。

0 个答案:

没有答案