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

feat: tlspolicy enforced condition #635

Merged
merged 1 commit into from
May 13, 2024
Merged

Conversation

KevFan
Copy link
Contributor

@KevFan KevFan commented May 9, 2024

Description

Closes: #572

Add enforced condition for TLSPolicy. This is based on whether the underlying Issuer and Certificates are in a Ready state.

Verification

Happy path is integration tested but if you want to verify manually

  • Checkout this branch
  • Deploy
make local-setup
  • Deploy policy
kubectl apply -n istio-system -f - <<EOF
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: istio-ingressgateway
spec:
  gatewayClassName: istio
  listeners:
  - name: http
    hostname: '*.toys.io'
    port: 443
    protocol: HTTPS
    tls:
      mode: Terminate
      certificateRefs:
      - name: toys
        kind: Secret
    allowedRoutes:
      namespaces:
        from: All    
---
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: selfsigned-issuer
spec:
  selfSigned: {}
---
apiVersion: kuadrant.io/v1alpha1
kind: TLSPolicy
metadata:
  name: gw-tls
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: Gateway
    name: istio-ingressgateway
  issuerRef:
    group: cert-manager.io
    kind: Issuer
    name: selfsigned-issuer
EOF
  • Check that the TLSPolicy has an enforced condition
kubectl get tlspolicy -A -o yaml | yq '.items[].status'
image
  • Check that there is a new column for the enforced condition
kubectl get tlspolicy -A -o wide 
image

@KevFan KevFan requested a review from a team as a code owner May 9, 2024 11:53
Copy link
Collaborator

@maleck13 maleck13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good.
I am starting to wonder if we need an enforced status per listener though. Doesn't need to be part of this PR

@KevFan KevFan force-pushed the issues/572 branch 3 times, most recently from 13bfb5f to 51d0cc8 Compare May 10, 2024 13:45
@KevFan KevFan changed the title [wip] feat: tlspolicy enforced condition feat: tlspolicy enforced condition May 10, 2024
Comment on lines +144 to +146
expectedCertificates := r.expectedCertificatesForGateway(ctx, gw.Gateway, tlsPolicy)

for _, cert := range expectedCertificates {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is what we want but there's no error if len(expectedCerificates) == 0 since this is already allowed at:

so I've kept it the same. In this case a TLSPolicy is still marked as enforced: true even if there are no Certificates created

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is ok. If there are no expected certificates then we have done everything we can to enforce

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.

TLSPolicy Enforced Status
2 participants