I'm deploying my config server and application which uses it to initalize properties.
The following problem I encounter now is the URI to specify where the config-server is located.
Before it was easy like this:
spring.config.import=optional:configserver:https://localhost:8888/
Now in the cluster I try to specify it like this
spring.config.import=optional:configserver:centralconfig-service:8888/
This the service name of the config-server (deployment name is 'centralconfig').
Whenever I try this URL i get an Invalid Url exception.
Invalid URL: centralconfig-service:8888/
I've set up an internal network so they should be able to communicate with eachother.
Anyone knows how to specify the correct URI in the kubernetes-environment?
centralconfig-deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: central-config
labels:
app: central-config
spec:
replicas: 1
selector:
matchLabels:
app: central-config
strategy: {}
template:
metadata:
labels:
app: central-config
spec:
containers:
- name: central-config
image: "central-config:latest"
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8888
resources: {}
restartPolicy: Always
serviceAccountName: ""
volumes: null
status: {}
centralconfig.service.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: central-config
labels:
app: central-config
spec:
replicas: 1
selector:
matchLabels:
app: central-config
strategy: {}
template:
metadata:
labels:
app: central-config
spec:
containers:
- name: central-config
image: "central-config:latest"
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8888
resources: {}
restartPolicy: Always
serviceAccountName: ""
volumes: null
status: {}
endpoints:
Thanks in advance
I suspect that missing the "http://" or "https://" prefix is the actual cause of the problem.
So give this one a try:
spring.config.import=optional:configserver:https://centralconfig-service:8888/
Related
I am running two docker images on my local minikube and this is my deployment file.
Somehow services for this yml file are not being shown in the viz dashboard.
How do I get them on viz dashboard of linkerd?
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: mux
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: lux
---
apiVersion: v1
kind: Service
metadata:
name: lux
spec:
type: ClusterIP
selector:
app: lux
ports:
- name: http
port: 9000
targetPort: 8000
---
apiVersion: v1
kind: Service
metadata:
name: mux
spec:
type: ClusterIP
selector:
app: mux
ports:
- name: http
port: 9001
targetPort: 8001
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: lux
labels:
app: lux
spec:
replicas: 1
selector:
matchLabels:
app: lux
template:
metadata:
labels:
app: lux
spec:
containers:
- name: lux
image: luxapp:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8000
serviceAccountName: lux
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mux
labels:
app: mux
spec:
replicas: 1
selector:
matchLabels:
app: mux
template:
metadata:
labels:
app: mux
spec:
containers:
- name: mux
image: muxapp:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8001
serviceAccountName: mux
---
I have only two components lux and mux and I want to deploy them on linkerd. When I inject them on linkerd only pods are created. service and service accounts are skipped.But on kubectl services are present.
I have following scenario
FastAPI (API Gateway)
Users (gRPC service)
below is the deployment yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: users
labels:
app: users
version: v1
spec:
replicas: 1
selector:
matchLabels:
app: users
version: v1
template:
metadata:
labels:
app: users
version: v1
spec:
containers:
- image: users:v0.0.1
imagePullPolicy: Always
name: svc
ports:
- containerPort: 9090
---
kind: Service
apiVersion: v1
metadata:
name: users
labels:
app: users
spec:
selector:
app: users
ports:
- name: grpc
protocol: TCP
port: 9090
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: fastapi
labels:
app: fastapi
version: v1
spec:
replicas: 1
selector:
matchLabels:
app: fastapi
version: v1
template:
metadata:
labels:
app: fastapi
version: v1
spec:
containers:
- image: fastapi:latest
imagePullPolicy: Always
name: web
ports:
- containerPort: 8080
env:
- name: USERS_SVC
value: 'users:9090'
---
kind: Service
apiVersion: v1
metadata:
name: fastapi
labels:
app: fastapi
spec:
selector:
app: fastapi
ports:
- port: 8080
name: http
After this I tried to test virtual service and route to users service (version: v2) when https header is passed. below is the codes for virtual service and destination rules
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: users-service-destination-rule
spec:
host: users
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: users-virtual-service
spec:
hosts:
- users
http:
- match:
- headers:
x-user-testing:
exact: tester
route:
- destination:
host: users
subset: v2
- route:
- destination:
host: users
subset: v1
Below is the deployment for user service (version v2)
apiVersion: apps/v1
kind: Deployment
metadata:
name: users-v2
labels:
app: users
version: v2
spec:
replicas: 1
selector:
matchLabels:
app: users
version: v2
template:
metadata:
labels:
app: users
version: v2
spec:
containers:
- image: users:v0.0.1
imagePullPolicy: Always
name: svc
ports:
- containerPort: 9090
When i passed header value, the request always goes to version v1.
curl -H "x-user-testing: tester" localhost/users
Can anyone help me please.
Thanks in advance
I have a simple Springboot service, which works well when I configure Service of type:LoadBalancer. But when I use service of type:ClusterIP and introduce ingress, it does not work
For that matter, I am unable to get Ingress working for any of my deployments in Azure/AKS.
Please suggest what am I missing
Spring code
#RestController
#RequestMapping("/demo")
public class MyController {
#GetMapping("/welcome")
public String welcome() {
return "Hello Welcome";
}
}
LoadBalancer - working code
spring-microservice-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: spring-microservice
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: spring-microservice
template:
metadata:
labels:
app: spring-microservice
spec:
containers:
- name: spring-microservice
image: babaacr.azurecr.io/welcome-service:1.0
resources:
requests:
memory: '256Mi'
cpu: '500m'
limits:
memory: '512Mi'
cpu: '1'
ports:
- name: http
containerPort: 8080
spring-microservice-service.yaml
apiVersion: v1
kind: Service
metadata:
name: spring-microservice
namespace: default
labels:
app: spring-microservice
spec:
selector:
app: spring-microservice
type: LoadBalancer
ports:
- name: http
port: 8080
targetPort: 8080
protocol: TCP
when I access the url http://20.XXX.XX.XX:8080/demo/welcome
message is printed
ingress based which is not working
apiVersion: apps/v1
kind: Deployment
metadata:
name: spring-microservice-x
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: spring-microservice-x
template:
metadata:
labels:
app: spring-microservice-x
spec:
containers:
- name: spring-microservice-x
image: babaacr.azurecr.io/welcome-service:1.0
resources:
requests:
memory: '256Mi'
cpu: '500m'
limits:
memory: '512Mi'
cpu: '1'
ports:
- name: http
containerPort: 8080
apiVersion: v1
kind: Service
metadata:
name: spring-microservice-x
namespace: default
labels:
app: spring-microservice-x
spec:
selector:
app: spring-microservice-x
type: ClusterIP
ports:
- name: http
port: 8080
targetPort: 8080
protocol: TCP
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: spring-microservice-ingress
spec:
defaultBackend:
service:
name: spring-microservice-x
port:
number: 8080
when I access the url http://20.YYY.YY.YY:8080/demo/welcome
the page times-out
ingress controller is configured using below
helm install ingress-nginx ingress-nginx/ingress-nginx --set controller.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-health-probe-request-path"=/healthz
I am trying to use "hostNetwork" flag to make my POD communicating over the node's network interface. But after adding this flag the config is not injected from the configmap but the default values from "application.properties" are used instead. Is that expected behavior ?
Note: when I remove the "hostNetwok" flag the app values are injected from the configmap.
I am working on kubernetes V 1.19.
deployment.yaml :
apiVersion: apps/v1
kind: Deployment
metadata:
name: dummy-service-deployment
labels:
app: dummy-service
spec:
replicas: 1
selector:
matchLabels:
app: dummy-service
template:
metadata:
labels:
app: dummy-service
spec:
hostNetwork: true
containers:
- name: dummy-service
image: dummyService:2.10.0
ports:
- containerPort: 8081
bootstrap.yaml:
spring:
application:
name: dummy-service
cloud:
kubernetes:
reload:
enabled: true
mode: polling
period: 10000
config:
sources:
- name: dummy-service-cm
Many thanks in advance ...
I am trying to my spring boot micro service in GKE Cluster with istio 1.1.5 latest version as of now. It throws error and pod never spins up. If I run it as a separate service in Kubernetes engine it works perfectly but with isito, it does not work. The purpose for using istio is to host multiple microservices and to use the feature istio provides. Here is my yaml file:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: revenue
spec:
replicas: 1
template:
metadata:
labels:
app: revenue-serv
tier: backend
track: stable
spec:
containers:
- name: backend
image: "gcr.io/finacials/revenue-serv:latest"
imagePullPolicy: Always
ports:
- containerPort: 8081
livenessProbe:
httpGet:
path: /
port: 8081
initialDelaySeconds: 15
timeoutSeconds: 30
readinessProbe:
httpGet:
path: /
port: 8081
initialDelaySeconds: 15
timeoutSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
name: revenue-serv
spec:
ports:
- port: 8081
#targetPort: 8081
#protocol: TCP
name: http
selector:
app: revenue-serv
tier: backend
type: LoadBalancer
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: gateway
annotations:
kubernetes.io/ingress.class: "istio"
spec:
rules:
- http:
paths:
- path: /revenue/.*
backend:
serviceName: revenue-serv
servicePort: 8081
Thanks for your valuable feedback.
I have found the issue. I removed readynessProbe and livenessProbe and created ingressgateway and virtual service. It worked.
deployment & service:
#########################################################################################
# This is for deployment - Service & Deployment in Kubernetes ################
# Author: Arindam Banerjee ################
#########################################################################################
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: revenue-serv
namespace: dev
spec:
replicas: 1
template:
metadata:
labels:
app: revenue-serv
version: v1
spec:
containers:
- name: revenue-serv
image: "eu.gcr.io/rcup-mza-dev/revenue-serv:latest"
imagePullPolicy: Always
ports:
- containerPort: 8081
---
apiVersion: v1
kind: Service
metadata:
name: revenue-serv
namespace: dev
spec:
ports:
- port: 8081
name: http
selector:
app: revenue-serv
gateway.yaml
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: worldcup-serv-gateway
namespace: dev
spec:
selector:
istio: ingressgateway # use istio default controller
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
virtual-service.yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: revenue-serv-virtualservice
namespace: dev
spec:
hosts:
- "*"
gateways:
- revenue-serv-gateway
http:
- route:
- destination:
host: revenue-serv