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

Backport of Fix ingress into release/1.1.x #2689

Conversation

hc-github-team-consul-core
Copy link
Collaborator

Backport

This PR is auto-generated from #2687 to be assessed for backporting due to the inclusion of the label backport/1.1.x.

The below text is copied from the body of the original PR.


  • blank line between rules: and - host:
  • ingressClass was present when no value was specified

Changes proposed in this PR:

Fix malformed ingress when using the helm chart.

Given this values.yaml snippet:

ui:
  enabled: true
  ingress:
    enabled: true
    hosts:
    - host: consul.localhost

Output before changes:

---
# Source: consul/templates/ui-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: vault-consul-ui
  namespace: consul
  labels:
    app: consul
    chart: consul-helm
    heritage: Helm
    release: vault
    component: ui
spec:
  ingressClassName: 
  rules:
  
  - host: "consul.localhost"
    http:
      paths:
      - backend:
          service:
            name: vault-consul-ui
            port:
              number: 80
        path: /
        pathType: Prefix

Output after changes:

---
# Source: consul/templates/ui-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: consul-consul-ui
  namespace: consul
  labels:
    app: consul
    chart: consul-helm
    heritage: Helm
    release: consul
    component: ui
spec:
  rules:
  - host: "consul.localhost"
    http:
      paths:
      - backend:
          service:
            name: consul-consul-ui
            port:
              number: 80
        path: /
        pathType: Prefix

How I've tested this PR:

Used bats as shown at: https://github.com/hashicorp/consul-k8s/blob/main/CONTRIBUTING.md#testing-the-helm-chart

I am seeing a failure for this file, but it would fail before any changes I've made due to the default values file not including a host:

# hosts is a list of host name to create Ingress rules.
#
# ```yaml
# hosts:
# - host: foo.bar
# paths:
# - /example
# - /test
# ```
#
# @type: array<map>
hosts: []

bats consul/test/unit/ui-ingress.bats
ui-ingress.bats
 ✓ ui/Ingress: disabled by default
 ✓ ui/Ingress: enable with ui.ingress.enabled
 ✓ ui/Ingress: disable with ui.ingress.enabled
 ✓ ui/Ingress: disable with ui.ingress.enabled dash string
 ✗ ui/Ingress: no hosts by default
   (in test file consul/test/unit/ui-ingress.bats, line 48)
     `[ "${actual}" = "null" ]' failed
   ---
   # Source: consul/templates/ui-ingress.yaml
   apiVersion: networking.k8s.io/v1
   kind: Ingress
   metadata:
     name: release-name-consul-ui
     namespace: consul
     labels:
       app: consul
       chart: consul-helm
       heritage: Helm
       release: release-name
       component: ui
   spec:
     rules:

 ✓ ui/Ingress: hosts can be set
 ✓ ui/Ingress: exposes single port 80 when global.tls.enabled=false
 ✓ ui/Ingress: exposes single port 443 when global.tls.enabled=true and global.tls.httpsOnly=true
 ✓ ui/Ingress: exposes the port 80 when global.tls.enabled=true and global.tls.httpsOnly=false
 ✓ ui/Ingress: exposes the port 443 when global.tls.enabled=true and global.tls.httpsOnly=false
 ✓ ui/Ingress: no tls by default
 ✓ ui/Ingress: tls can be set
 ✓ ui/Ingress: tls with secret name can be set
 ✓ ui/Ingress: no annotations by default
 ✓ ui/Ingress: annotations can be set
 ✓ ui/Ingress: default PathType Prefix
 ✓ ui/Ingress: set PathType ImplementationSpecific
 ✓ ui/Ingress: no ingressClassName by default
 ✓ ui/Ingress: can set ingressClassName

19 tests, 1 failure

How I expect reviewers to test this PR:

Using the existing tests.

Checklist:


Overview of commits

@hc-github-team-consul-core hc-github-team-consul-core merged commit 80301a8 into release/1.1.x Jul 28, 2023
4 checks passed
@hc-github-team-consul-core hc-github-team-consul-core deleted the backport/ashwin/fix-ingress-template/happily-noble-krill branch July 28, 2023 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants