kubernetes-ingress icon indicating copy to clipboard operation
kubernetes-ingress copied to clipboard

SSL protocol error after controller upgrade

Open dfateyev opened this issue 2 years ago • 4 comments

I have upgraded HAProxy controller from an earlier to the latest version (1.8.3). Unfortunately, an ingress resource for SSL-based backend (actually, the Kubernetes dashboard) stopped working.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard
  annotations:
    haproxy.org/path-rewrite: /kubernetes-dashboard(/|$)(.*) /\2
    haproxy.org/server-ssl: 'true'
    haproxy.org/check: 'false'
spec:
  ingressClassName: haproxy
  rules:
  - http:
      paths:
      - path: /kubernetes-dashboard
        pathType: Prefix
        backend:
          service:
            name: kubernetes-dashboard
            port:
              number: 443

Now, I have "502 Bad Gateway" error in HAProxy frontend, and in dashboard logs:

2022/07/21 09:25:51 http2: server connection error from 10.239.96.1:49972: connection error: PROTOCOL_ERROR
2022/07/21 09:25:52 http2: server connection error from 10.239.128.2:51292: connection error: PROTOCOL_ERROR

What can be wrong in this configuration? It worked fine at least for 1.6.x controller versions.

If I remove the "server-ssl" annotation, I get "Client sent an HTTP request to an HTTPS server" valid error as expected.

dfateyev avatar Jul 21 '22 09:07 dfateyev

Hi @ivanmatmati, could you check this — it looks like a regression after 1.6.

dfateyev avatar Jul 22 '22 12:07 dfateyev

Hi @dfateyev , I'll do as soon as possible. Thanks.

ivanmatmati avatar Jul 25 '22 13:07 ivanmatmati

@ivanmatmati sorry for pinging, did you have a chance to check this issue?

dfateyev avatar Aug 22 '22 06:08 dfateyev

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 21 '22 13:09 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 21 '22 17:10 stale[bot]

@oktalz please remove the stale label from this issue, thanks!

dfateyev avatar Oct 24 '22 10:10 dfateyev

@oktalz I have reproduced it under 1.8.8 and 1.9.0, are there any updates?

dfateyev avatar Nov 09 '22 15:11 dfateyev

Following the documentation I could reach the UI through Ingress Controller. As it's an HTTP service, you should call it without ssl at all.

ivanmatmati avatar Nov 10 '22 10:11 ivanmatmati

Following the documentation I could reach the UI through Ingress Controller. As it's an HTTP service, you should call it without ssl at all.

@ivanmatmati could you provide more detail how you managed to do it? Dashboard exposes HTTPS endpoint via Service, not a plain HTTP: see deployment from the link above. Addressing it via HTTP haproxy.org/server-ssl: "false" gives Client sent an HTTP request to an HTTPS server error.

dfateyev avatar Nov 10 '22 10:11 dfateyev

I just followed the documentation for dashboard installation and then removed the server-ssl annotation.

ivanmatmati avatar Nov 10 '22 12:11 ivanmatmati

I just followed the documentation for dashboard installation and then removed the server-ssl annotation.

The documentation implies kubectl proxy usage and no ingress. If you ingress what is already proxied by kubectl proxy — then it will be probably work, since kubectl proxy retrieves plain HTTP.

In our case, we want to ingress kubernetes-dashboard service directly, see the message above. It worked fine for 1.6.x, as expected, but stopped to work for later versions, failing with PROTOCOL_ERROR while accessing the endpoint. In general, there is an issue accessing SSL-based endpoints.

dfateyev avatar Nov 10 '22 13:11 dfateyev

@ivanmatmati sorry for pinging, but this issue blocks us from controller upgrade to the latest version (we have to keep 1.6 version, where this functionality works). I can provide more details about the issue if needed, although it can be easily reproduced.

dfateyev avatar Nov 29 '22 12:11 dfateyev

@dfateyev , I can't say much more than I said. For documentation I only talked about installation of dashboard, I don't refer to the rest. So to clarify things:

  1. kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.1/aio/deploy/recommended.yaml
  2. apply the ingress.
  3. Reach the dashboard through http frontend of haproxy. First, I reached a blank page because I couldn't get the js files because of mapping with /kubernetes-dashboard, I just replaced it with / and all worked! It was done with latest Ingress Controller code. Please retry with a fresh cluster.

ivanmatmati avatar Nov 30 '22 16:11 ivanmatmati

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 30 '22 19:12 stale[bot]

Unstale the issue

dfateyev avatar Dec 31 '22 04:12 dfateyev

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 30 '23 04:01 stale[bot]

Unstale the issue

dfateyev avatar Jan 30 '23 16:01 dfateyev

Hi @dfateyev , did you try the thing I've indicated ? We can't keep this issue open if there's no activity on it.

ivanmatmati avatar Jan 30 '23 16:01 ivanmatmati

did you try the thing I've indicated ? We can't keep this issue open if there's no activity on it.

I will retry, and let you know. Last time it didn't worked, I need to dig it once more.

dfateyev avatar Jan 30 '23 20:01 dfateyev

@ivanmatmati I think, I get the reason of the issue. Could you re-check?

$ curl --http1.1 http://<haproxy-ip>/kubernetes-dashboard/
<valid content>

$ curl --http2 http://<haproxy-ip>/kubernetes-dashboard/
<html><body><h1>502 Bad Gateway</h1>
The server returned an invalid or incomplete response.
</body></html>

2023/02/03 20:52:27 http2: server connection error from 10.239.192.2:60814: connection error: PROTOCOL_ERROR
2023/02/03 20:54:20 http2: server connection error from 10.239.192.2:46358: connection error: PROTOCOL_ERROR

If I revert to controller 1.6.9, HTTP/2 is handled correctly:

$ curl --http1.1 http://<haproxy-ip>/kubernetes-dashboard/
<valid content>

$ curl --http2 http://<haproxy-ip>/kubernetes-dashboard/
<valid content>

upstream Nginx balancer with http/2 support + client browser:
<http/2.0 based valid content>

2023/02/03 21:55:11 [2023-02-03T21:55:11Z] Incoming HTTP/2.0 GET /api/v1/plugin/config request from x.x.x.x:
2023/02/03 21:55:11 Getting application global configuration
2023/02/03 21:55:11 Application configuration {"serverTime":1675461311811}
2023/02/03 21:55:11 [2023-02-03T21:55:11Z] Outcoming response to x.x.x.x with 200 status code
2023/02/03 21:55:11 [2023-02-03T21:55:11Z] Incoming HTTP/2.0 GET /api/v1/settings/global request from x.x.x.x:
2023/02/03 21:55:11 [2023-02-03T21:55:11Z] Outcoming response to x.x.x.x with 200 status code
2023/02/03 21:55:11 [2023-02-03T21:55:11Z] Incoming HTTP/2.0 GET /api/v1/settings/pinner request from x.x.x.x:
2023/02/03 21:55:11 [2023-02-03T21:55:11Z] Outcoming response to x.x.x.x with 200 status code
2023/02/03 21:55:11 [2023-02-03T21:55:11Z] Incoming HTTP/2.0 GET /api/v1/settings/global request from x.x.x.x:
2023/02/03 21:55:11 [2023-02-03T21:55:11Z] Outcoming response to x.x.x.x with 200 status code

dfateyev avatar Feb 03 '23 22:02 dfateyev

@ivanmatmati have you checked this issue, with new details provided? It looks like the issue can be reproduced with http2-based client after the controller update, but worked for older versions.

dfateyev avatar Feb 27 '23 09:02 dfateyev

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 29 '23 10:03 stale[bot]

Please unstale. I believe the case described can be considered.

dfateyev avatar Mar 30 '23 18:03 dfateyev

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 29 '23 20:04 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 31 '23 18:05 stale[bot]

Unstale the issue

dfateyev avatar Jun 04 '23 21:06 dfateyev

Hi @dfateyev , I thought I answered you but it's not the case. After some tests, it appears that the question is more related to haproxy. I've observed the same thing as you. The thing is that 1.6.9 uses HAProxy 2.3 while 1.9 uses 2.6. It seems that the difference is at HAProxy level. I've swapped the configuration (with a few adaptations) and it does nothing, so I assume this is not related to the configuration file itself.My best advice would be to report this issue in HAProxy repository with the explanations.

ivanmatmati avatar Jun 08 '23 11:06 ivanmatmati

@ivanmatmati IMO it's too early to close this ticket: the discussion in escalation isn't finished. BTW, do you have an idea about upgrade options mentioned there? Another question: do we have headers filtering mechanism in the controller now, either for a single ingress resource or for global?

dfateyev avatar Jun 15 '23 13:06 dfateyev

Hi @dfateyev , I close this issue as there's an other one ongoing in haproxy repository. We can't multiply issues or keep it without activity. If necessary it will be reopen. I'm afraid I don't have any idea about connection upgrade, I'll do some research and keep you informed if any interesting finding. Thanks.

ivanmatmati avatar Jun 16 '23 05:06 ivanmatmati