问题描述
我正在开发Spring Cloud Dataflow Stream应用程序.我能够使用Cloud Foundry中运行的船长来运行Spring云数据流服务器.现在,即使我在部署中的环境配置中明确给出了用户名,我仍试图与在kubernetes集群中运行的船长运行相同的代码,并在部署时遇到错误.
I am working on spring cloud dataflow stream app. I am able to run Spring cloud data flow server with the skipper running in Cloud Foundry . Now i am trying to run the same with the skipper running in kubernetes cluster and getting below error on deployment even though i am explicitly giving the username in the environment config in deployment.
用于Kubernetes部署的SKIPPER YML
apiVersion: apps/v1
kind: Deployment
metadata:
name: skipper-server
labels:
app: skipper-server
spec:
replicas: 1
selector:
matchLabels:
app: skipper-server
template:
metadata:
labels:
app: skipper-server
annotations:
kubernetes.io/psp: nonroot
spec:
containers:
- name: skipper-server
image: <image_location>
imagePullPolicy: Always
ports:
- containerPort: 7577
protocol: TCP
resources:
limits:
cpu: "4"
memory: 2Gi
requests:
cpu: 25m
memory: 1Gi
securityContext:
runAsUser: 99
env:
- name: "SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_MASTER_URL"
value: "<kubernetes_master_url>:6443"
- name: "SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_USERNAME"
value: "<user>"
- name: "SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_PASSWORD"
value: "<pwd>"
- name: "SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_NAMESPACE"
value: "<namespace>"
- name: "SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_TRUST_CERTS"
value: "true"
- name: "SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_CREATE_LOAD_BALANCER"
value: "true"
完整堆栈
Caused by: io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: GET at: <kubernetes_cluster_url:6443/api/v1/namespaces/pocdev/services?labelSelector=spring-app-id%3Dtest444-pocclient . Service account may have been revoked. services is forbidden: User "system:anonymous" cannot list resource "services" in API group "" in the namespace "poc-dev". at io.fabric8.kubernetes.client.dsl.base.OperationSupport.requestFailure(OperationSupport.java:476) ~[kubernetes-client-4.1.0.jar!/:na] at io.fabric8.kubernetes.client.dsl.base.OperationSupport.assertResponseCode(OperationSupport.java:413) ~[kubernetes-client-4.1.0.jar!/:na]
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:381) ~[kubernetes-client-4.1.0.jar!/:na]
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:344) ~[kubernetes-client-4.1.0.jar!/:na]
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:328) ~[kubernetes-client-4.1.0.jar!/:na]
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.list(BaseOperation.java:598) ~[kubernetes-client-4.1.0.jar!/:na]
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.list(BaseOperation.java:63) ~[kubernetes-client-4.1.0.jar!/:na]
at org.springframework.cloud.deployer.spi.kubernetes.KubernetesAppDeployer.status(KubernetesAppDeployer.java:196) ~[spring-cloud-deployer-kubernetes-2.0.2.RELEASE.jar!/:2.0.2.RELEASE]
at org.springframework.cloud.deployer.spi.kubernetes.KubernetesAppDeployer.deploy(KubernetesAppDeployer.java:103) ~[spring-cloud-deployer-kubernetes-2.0.2.RELEASE.jar!/:2.0.2.RELEASE]
at org.springframework.cloud.skipper.server.deployer.DefaultReleaseManager.install(DefaultReleaseManager.java:115) ~[spring-cloud-skipper-server-core-2.0.3.RELEASE.jar!/:2.0.3.RELEASE]
... 50 common frames omitted
推荐答案
当我从env属性列表中删除以下属性,并且船长开始使用默认服务而非我的用户帐户时,此问题已得到解决
This got fixed when i removed below properties from the env properties list and skipper started using the default service instead of my user account
- 名称:"SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_USERNAME" 价值: "" -名称:"SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_PASSWORD" 值:"
- name: "SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_USERNAME" value: "" - name: "SPRING_CLOUD_SKIPPER_SERVER_PLATFORM_KUBERNETES_ACCOUNTS_K8S_FABRIC8_PASSWORD" value: ""
这篇关于Kubernetes上的Spring Cloud Dataflow部署时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!