Angular应用程序无法从部署在GoogleKubernetesEngine中的SpringBootAPI呈现数据。
创始人
2024-10-30 14:00:35
0
  1. 确保Spring Boot API正确部署在Kubernetes Engine中,并具有正确的服务和端口配置。
  2. 在Angular应用程序中使用HttpClient模块进行HTTP调用。确保使用正确的URL和端口号。
import { HttpClient } from '@angular/common/http';

@Injectable({
  providedIn: 'root'
})
export class DataService {

  constructor(private http: HttpClient) { }
  
  getData() {
    return this.http.get('http://:/data');
  }
}
  1. 为Kubernetes Service添加正确的标签和选择器,以匹配Pod标签,确保正确路由到正确的Pod。
apiVersion: v1
kind: Service
metadata:
  name: spring-boot-api-service-name
spec:
  selector:
    app: spring-boot-app
    tier: backend
  ports:
    - name: http
      protocol: TCP
      port: 8080
      targetPort: 8080
  1. 如果使用了Ingress控制器,则需要为Ingress规则添加正确的路径和后端服务。确保Ingress和Kubernetes Service配置一致。
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: spring-boot-api-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
    - http:
        paths:
          - path: /data
            pathType: Prefix
            backend:
              service:
                name: spring-boot-api-service-name
                port:
                  name: http

相关内容

热门资讯

透视技巧!wepoker数据分... 透视技巧!wepoker数据分析(透视)wepoker可以透视码(一直一直都是有透视)-哔哩哔哩1、...
透视方法!wepoker私人局... 透视方法!wepoker私人局俱乐部(透视)wepoker私人局有透视吗(本来一直都是有辅助器)-哔...
透视技巧!wepoker祈福有... 透视技巧!wepoker祈福有用吗(透视)wejoker免费脚本(果然一直都是有脚本)-哔哩哔哩1、...
透视app!wpk辅助购买(透... 透视app!wpk辅助购买(透视)wpk俱乐部是真的吗(都是存在有透视)-哔哩哔哩1、每一步都需要思...
透视攻略!德普之星透视辅助软件... 透视攻略!德普之星透视辅助软件(透视)德普之星透视辅助插件(竟然存在有辅助器)-哔哩哔哩一、德普之星...
透视app!hhpoker哪个... 透视app!hhpoker哪个俱乐部靠谱(透视)hhpoker有没有作必弊辅助(竟然是真的有透视)-...
透视技巧!wepoker可以透... 透视技巧!wepoker可以透视码(透视)wepoker辅助器安装包定制(一直一直都是有挂)-哔哩哔...
透视软件!wepoker免费透... 透视软件!wepoker免费透视脚本(透视)wepoker透视有用吗(总是有脚本)-哔哩哔哩小薇(辅...
透视攻略!wepokerplu... 透视攻略!wepokerplus脚本(透视)wepoker透视方法(一贯是真的有挂)-哔哩哔哩1、w...
透视技巧!hhpoker买挂(... 透视技巧!hhpoker买挂(透视)hhpoker到底可以作必弊码(原来存在有挂)-哔哩哔哩1)hh...