Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Communication between pods should happen through SSL on Openshift/K8S when I set "secured"service annotation to true #1141

Closed
fgapito opened this issue Nov 18, 2022 · 14 comments · Fixed by #1151
Labels
Milestone

Comments

@fgapito
Copy link
Contributor

fgapito commented Nov 18, 2022

Hi,

I'm facing with this possible issue when I try to establish a https/ssl connection from A->B (B has secured annotation on k8s service annotation). It seems that the annotation it is loaded but it is not used to set secure = true inside the KubernetesServiceInstance object. I checked in the KubernetesInformerDiscoveryClient and I see this at line 163 (v 2.1.3)

image

You can see that secure constructor parameter is always false.

Is it normal? Why, even if I put annotation on service description, the service B is called through http instead of https?

This is the reference to the documentation where secured annotation is mentioned:
image

https://docs.spring.io/spring-cloud-kubernetes/docs/2.1.1/reference/html/#loadbalancer-for-kubernetes

Thank you

Kind Regards

f

@ryanjbaxter
Copy link
Contributor

That doc is specific to the load balancer not service discovery.

Do you have an https port defined in your service resource?
See the bottom of this section of the docs https://docs.spring.io/spring-cloud-kubernetes/docs/2.1.1/reference/html/#discoveryclient-for-kubernetes

@fgapito
Copy link
Contributor Author

fgapito commented Nov 23, 2022

Yes I have it and the name is "main". I also configured spring cloud discovery to use main as primary port with the appropriate configuration. I also tried renaming that port in "Https". I hacked that class reading the secured annotation value and it works but this is just a bad patch and I do not want to put that in production.

@ryanjbaxter
Copy link
Contributor

Can you tell me how you are using the discovery client to make the request?

@fgapito
Copy link
Contributor Author

fgapito commented Nov 24, 2022

I'm using these deps:

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-kubernetes-client-discovery</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-loadbalancer</artifactId>
        </dependency>

The rest call is executed using Feign.

The client spring boot service has this configuration:


spring:
  cloud:
    kubernetes:
      discovery:
        primary-port-name: 'main'
      config:
        enabled: false

this is the serice definition of the target service to be called with https

apiVersion: v1
kind: Service
metadata:
  name: target-svc
  annotations:
    secured: 'true'
spec:
  ports:
    - name: main
      protocol: TCP
      port: 44389
      targetPort: 44389
  selector:
    app: target-svc

Let me know if I can give you more info.

F

@ryanjbaxter
Copy link
Contributor

Thanks. How are you making the http request to the service?

@fgapito
Copy link
Contributor Author

fgapito commented Nov 24, 2022

Using feign

@FeignClient(name = "target-svc", configuration = MyFeignConfig.class)

@fgapito
Copy link
Contributor Author

fgapito commented Nov 25, 2022

This is the change that let the https call happen:

image

@ryanjbaxter
Copy link
Contributor

Would you be interested in submitting a PR?

@fgapito
Copy link
Contributor Author

fgapito commented Nov 25, 2022

Of course, I'm going to do that.

Thank you.

@fgapito
Copy link
Contributor Author

fgapito commented Nov 27, 2022

Here the PR requested.

#1150

and also this for 2.1.X branch

#1151

I think a mantainer should approve

image

Let me know if I missed something.

Thank you.

@ryanjbaxter ryanjbaxter modified the milestones: 2.1.6, 3.0.0 Dec 5, 2022
@ryanjbaxter ryanjbaxter moved this to Done in 2021.0.5 Dec 5, 2022
@fgapito
Copy link
Contributor Author

fgapito commented Jan 22, 2023

HI,

do you know approximatively when the spring-cloud-kubernetes version 2.1.6 (that should contains this fix) will be pushed on official maven repositories?

thank you.

f

@ryanjbaxter
Copy link
Contributor

@fgapito
Copy link
Contributor Author

fgapito commented Feb 17, 2023

Hi, I tought it was DONE in 2021.0.5 but it seems not. Did something go wrong or should I wait for 2021.0.6?
f

@ryanjbaxter
Copy link
Contributor

2021.0.5 was released on November 3rd, we didn't merge this till December 6th it will be included in 2021.0.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
3 participants