小编wpe*_*per的帖子

Gcloud Kubernetes 连接拒绝暴露服务

我无法连接到部署在 Google Can Kubernetes 上的 docker 容器的公开 IP。我一直在大致遵循本教程但使用的是我自己的应用程序。

部署似乎工作正常,访问云仪表板时一切都是绿色的并且正在运行,但是当尝试访问公开 IP 上的已部署应用程序时,我收到浏览器错误:

无法访问此站点 35.231.27.158 拒绝连接

如果我ping IP,我会得到回复。

kubectl get pods 产生以下内容:

NAME                        READY     STATUS    RESTARTS   AGE
mtg-dash-7874f6c54d-nktjn   1/1       Running   0          21m
Run Code Online (Sandbox Code Playgroud)

kubectl get service显示以下内容:

NAME         TYPE           CLUSTER-IP     EXTERNAL-IP     PORT(S)        AGE
kubernetes   ClusterIP      10.7.240.1     <none>          443/TCP        23m
mtg-dash     LoadBalancer   10.7.242.240   35.231.27.158   80:30306/TCP   20m
Run Code Online (Sandbox Code Playgroud)

kubectl describe svc显示以下内容:

Name:                     mtg-dash
Namespace:                default
Labels:                   run=mtg-dash
Annotations:              <none>
Selector:                 run=mtg-dash
Type:                     LoadBalancer
IP:                       10.7.242.240
LoadBalancer Ingress:     35.231.27.158
Port:                     <unset>  80/TCP …
Run Code Online (Sandbox Code Playgroud)

docker google-cloud-platform kubernetes

7
推荐指数
1
解决办法
2293
查看次数

按年份分组对象数组

我正在尝试按年份对一组对象进行分组。

对于上下文,我有一个水平时间线图 (D3js),需要按年份对重叠日期进行分组。

我有以下数据:

[
  {times: [{color: 'red', year: 2031}]},
  {times: [{color: 'green', year: 2031}]},
  {times: [{color: 'blue', year: 2031}]},
  {times: [{color: 'purple', year: 2045}]},
  {times: [{color: 'orange', year: 2045}]},
]
Run Code Online (Sandbox Code Playgroud)

并试图将其变成以下形状(按年份分组):

[
  {times: [
    {color: 'red', year: 2031},
    {color: 'green', year: 2031},
    {color: 'blue', year: 2031}
  ]},
  {times: [
    {color: 'purple', year: 2045},
    {color: 'orange', year: 2045}
  ]}
]
Run Code Online (Sandbox Code Playgroud)

我曾尝试使用一些变体,reduce但似乎无法以我需要的形状获取数据:

data.reduce((result: any, current: any) => {
  const year = current.times[0].year;

  /* Not entirely sure what to do …
Run Code Online (Sandbox Code Playgroud)

javascript arrays typescript

4
推荐指数
1
解决办法
62
查看次数

AngularFire Firestore 属性“地图”在类型“Action&lt;DocumentSnapshot&lt;any&gt;&gt;”上不存在

我正在关注关于集合的firebase 文档,但在尝试检索具有文档 ID 的文档集合时,无法弄清楚为什么我的代码无法按照文档工作。

我的 IDE 显示以下错误:

类型“Action< DocumentSnapshot< any>>”上不存在属性“map”。

对于以下代码:

this.userDocRef = this.afs.doc<any>(`users/${user.uid}`);
this.userDoc$ = this.userDocRef.snapshotChanges().pipe(
  map(actions => {
    return actions.map(a => { // error throws here
      const data = a.payload.doc.data() as any;
      const id = a.payload.doc.id;
      return { id, ...data };
    })
  })
)
Run Code Online (Sandbox Code Playgroud)

当我运行此代码时,出现以下错误:

错误类型错误:actions.map 不是函数

我如何重构它以使其正常工作?

"firebase": "^5.0.4"
"@angular/core": "^6.1.0"
"angularfire2": "^5.0.0-rc.10"
Run Code Online (Sandbox Code Playgroud)

firebase angularfire2 angular google-cloud-firestore

3
推荐指数
1
解决办法
1883
查看次数