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

[NET-9420] clean up acl role policy for apigw #4060

Merged
merged 8 commits into from
Jun 4, 2024

Conversation

jm96441n
Copy link
Member

@jm96441n jm96441n commented May 30, 2024

Changes proposed in this PR

previously all gateways shared the same acl role and policy so when deleting a gateway the policy/role did not need to be removed. With the changes to reduce the scope of gateway acls and make them a 1:1 mapping from role/policy to gateway we now need to clean up the role/policy when a gateway is removed.

How I've tested this PR

  • Wrote tests

Repro Steps:

  1. on this branch run make dev-docker and for consul pull latest main and run make dev-docker to generate the images we'll be testing with
  2. clone the following gist: https://gist.github.com/jm96441n/b92a80c2251c7a54d1feada320c5eac6
  3. in the start.sh file of the gist update the CONSUL_K8S_CHART_LOCATION variable on line 5 to point to the location of the charts directory in consul-k8s on your machine
  4. run the start.sh script, this creates your kind cluster, loads the consul-k8s and consul images into the cluster, installs consul, and sets up 2 api-gateways
  5. run kubectl port-forward service/consul-consul-ui 8501:443 -n consul in a separate terminal window to port forward to consul
  6. to copy the acl token needed to login run
# macos
kubectl get --namespace consul secrets/consul-consul-bootstrap-acl-token --template={{.data.token}} | base64 -d | pbcopy

# linux
kubectl get --namespace consul secrets/consul-consul-bootstrap-acl-token --template={{.data.token}} | base64 -d | xsel -clipboard
  1. open your browser and visit https://localhost:8501 and navigate through the untrusted cert warnings
  2. login using the login token we copied previously
  3. view the policies page and you should see an entry for each of the api-gateways
  4. remove one of the gateways by running kubectl delete -f gw2.yaml and see the policy get removed (the same will happen for roles)
  5. put the gateway back by running kubectl apply -f gw2.yaml and see the policy come back

How I expect reviewers to test this PR

read the code
run the above steps

To run the acceptance test:

  1. run kind create cluster
  2. build the control plane from this branch using make dev-docker
  3. load the image into the cluster by running kind load docker-image consul-k8s-control-plane:local
  4. cd into the api-gateway directory cd ./acceptance/tests/api-gateway
  5. run go test -consul-k8s-image=consul-k8s-control-plane:local -run TestAPIGateway_Lifecycle -v ./... to run the test using the changes from this branch

Checklist

@jm96441n jm96441n changed the title Net 9420 clean up acl role policy for apigw [NET-9420] clean up acl role policy for apigw May 31, 2024
@jm96441n jm96441n added backport/1.2.x This release branch is no longer active. backport/1.3.x backport/1.4.x labels Jun 3, 2024
@jm96441n jm96441n requested review from a team, nathancoleman and missylbytes and removed request for a team June 3, 2024 16:38
Copy link
Member

@sarahalsmiller sarahalsmiller left a comment

Choose a reason for hiding this comment

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

Thanks for grabbing that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants