我有一个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"
时,我得到了回应。负载均衡器似乎出了点问题。