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

[ExternalNode] Create Secret for vm-agent in RBAC #4560

Merged
merged 1 commit into from
Feb 2, 2023

Conversation

wenyingd
Copy link
Contributor

@wenyingd wenyingd commented Jan 16, 2023

  1. Crate a separate Secret for VM Agent in RBAC file, because the Secret for a ServiceAccount is not created automatically since K8s v1.24.
  2. Use the manually created Secret in Agent kubeconfig file.

Fix #4558

Signed-off-by: wenyingd wenyingd@vmware.com

@wenyingd
Copy link
Contributor Author

/test-vm-e2e

Copy link
Contributor

@Anandkumar26 Anandkumar26 left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@@ -194,7 +194,7 @@ function create_kubeconfig_files {
# Kubeconfig to access K8S API

APISERVER=$(kubectl config view -o jsonpath="{.clusters[?(@.name==\"$CLUSTER_NAME\")].cluster.server}")
TOKEN=$(kubectl -n $TEST_NAMESPACE get secrets -o jsonpath="{.items[?(@.metadata.annotations['kubernetes\.io/service-account\.name']=='$SERVICE_ACCOUNT')].data.token}"|base64 --decode)
Copy link
Contributor

Choose a reason for hiding this comment

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

Any particular reason to change it to use Secret Name instead of ServiceAccount Name?

Copy link
Contributor Author

@wenyingd wenyingd Jan 16, 2023

Choose a reason for hiding this comment

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

This is to be compatible with the original K8s versions. After we changed the RBAC file for VM Agent, a new Secret with name "vm-agent-service-account-token" is always created. It should work fine with newer versions in K8s cluster as there is only one Secret (what is created by us) is found with the annotation "kubernetes.io/service-account.name: vm-agent". For previous versions, a default Secret is created along with the SA, there would be two Secrets found with the annotation, then the final token string is incorrect as a concat of two tokens. As a result, I change the script to leverage the Secret which must exist in both previous version and later version.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good. Thanks for the clarification.

@codecov
Copy link

codecov bot commented Jan 16, 2023

Codecov Report

Merging #4560 (91b0893) into main (bd0d275) will increase coverage by 5.78%.
The diff coverage is n/a.

❗ Current head 91b0893 differs from pull request most recent head 75565f7. Consider uploading reports for the commit 75565f7 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4560      +/-   ##
==========================================
+ Coverage   64.58%   70.36%   +5.78%     
==========================================
  Files         390      376      -14     
  Lines       57640    56059    -1581     
==========================================
+ Hits        37225    39448    +2223     
+ Misses      17760    13881    -3879     
- Partials     2655     2730      +75     
Flag Coverage Δ *Carryforward flag
e2e-tests 38.34% <ø> (ø) Carriedforward from bd0d275
integration-tests 34.57% <ø> (-0.01%) ⬇️
kind-e2e-tests 46.48% <ø> (ø) Carriedforward from bd0d275
unit-tests 59.15% <ø> (+3.46%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Impacted Files Coverage Δ
pkg/features/antrea_features.go 64.00% <0.00%> (-36.00%) ⬇️
pkg/flowaggregator/certificate.go 63.52% <0.00%> (-12.00%) ⬇️
pkg/config/flowaggregator/default.go 91.30% <0.00%> (-8.70%) ⬇️
pkg/agent/flowexporter/exporter/exporter.go 65.54% <0.00%> (-5.99%) ⬇️
pkg/util/env/env.go 58.73% <0.00%> (-4.77%) ⬇️
pkg/antctl/runtime/runtime.go 33.33% <0.00%> (-3.34%) ⬇️
...catesigningrequest/ipsec_csr_signing_controller.go 61.65% <0.00%> (-2.46%) ⬇️
pkg/agent/util/net_linux.go 30.43% <0.00%> (-1.52%) ⬇️
pkg/controller/externalnode/controller.go 66.16% <0.00%> (-1.51%) ⬇️
pkg/ipam/poolallocator/allocator.go 73.09% <0.00%> (-0.48%) ⬇️
... and 83 more

@wenyingd
Copy link
Contributor Author

/test-vm-e2e

1. Crate a separate Secret for VM Agent in RBAC file, this because the Secret for a ServiceAccount is not created automatically since K8s v1.24.
2. Use the manually created Secret in Agent kubeconfig file.

Signed-off-by: wenyingd <wenyingd@vmware.com>
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

@wenyingd
Copy link
Contributor Author

/skip-all
VM Agent e2e test has passed in CI setup.

@tnqn tnqn merged commit e848cef into antrea-io:main Feb 2, 2023
@wenyingd wenyingd deleted the issue_4558 branch May 30, 2023 06:47
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.

VM Agent is unable to communicate with Antrea/K8 API server on 1.24.6 K8s cluster.
3 participants