-
Notifications
You must be signed in to change notification settings - Fork 19
Add 3 labels to all resources, add e2e test that validate the existence of the three labels #142
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
Draft
Shai1-Levi
wants to merge
8
commits into
medik8s:main
Choose a base branch
from
Shai1-Levi:bugfix/ep2322
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9788816
1. Add custom label, propagate the label to all the right files.
52d10cf
1. Add custom label, propagate the label to all the right files.
3a3fa91
Fix labels:
aaf05ab
Fix labels:
ee4f3bc
Fix labels:
37e41e9
Fix labels:
807c5f9
Add 3 custom labels to all resources, add e2e test that validate the …
1827784
Refactor tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
bundle/manifests/node-maintenance-controller-manager-metrics-service_v1_service.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| creationTimestamp: null | ||
| labels: | ||
| app.kubernetes.io/component: controller-manager | ||
| app.kubernetes.io/name: node-maintenance-operator | ||
| node-maintenance-operator: "" | ||
| name: node-maintenance-controller-manager-metrics-service | ||
| spec: | ||
| ports: | ||
| - name: https | ||
| port: 8443 | ||
| protocol: TCP | ||
| targetPort: https | ||
| selector: | ||
| app.kubernetes.io/component: controller-manager | ||
| app.kubernetes.io/name: node-maintenance-operator | ||
| node-maintenance-operator: "" | ||
| status: | ||
| loadBalancer: {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
...le/manifests/node-maintenance-operator-controller-manager-metrics-service_v1_service.yaml
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -179,6 +179,11 @@ var _ = Describe("Starting Maintenance", func() { | |
| // it should be caused by the test deployment's termination graceperiod > drain timeout | ||
| Expect(getOperatorLogs()).To(ContainSubstring(nodemaintenance.FixedDurationReconcileLog)) | ||
|
|
||
| //validate that operator controller pod have app.kubernetes.io/name label | ||
| Expect(validateOperatorCustomLabelName()).To(BeTrue(), "operator label name validation failed") | ||
| Expect(validateOperatorCustomLabelComponent()).To(BeTrue(), "operator label component validation failed") | ||
| Expect(validateOperatorCustomLabelDefaultContainer()).To(BeTrue(), "operator label defaultContainer validation failed") | ||
|
|
||
| By("node should be unschedulable and tainted node") | ||
| node := &corev1.Node{} | ||
| err = Client.Get(context.TODO(), types.NamespacedName{Namespace: "", Name: maintenanceNodeName}, node) | ||
|
|
@@ -419,6 +424,26 @@ func getOperatorPod() *corev1.Pod { | |
| return &pods.Items[0] | ||
| } | ||
|
|
||
| func validateOperatorCustomLabelName() bool { | ||
| pods, err := KubeClient.CoreV1().Pods(operatorNsName).List(context.Background(), metav1.ListOptions{LabelSelector: "app.kubernetes.io/name=node-maintenance-operator"}) | ||
| ExpectWithOffset(2, err).ToNot(HaveOccurred(), "failed to get operator pods by label name") | ||
| ExpectWithOffset(2, len(pods.Items)).ToNot(BeZero(), "no operator pod found") | ||
| return true | ||
| } | ||
|
|
||
| func validateOperatorCustomLabelComponent() bool { | ||
|
||
| pods, err := KubeClient.CoreV1().Pods(operatorNsName).List(context.Background(), metav1.ListOptions{LabelSelector: "app.kubernetes.io/component=controller-manager"}) | ||
| ExpectWithOffset(2, err).ToNot(HaveOccurred(), "failed to get operator pods by label component") | ||
| ExpectWithOffset(2, len(pods.Items)).ToNot(BeZero(), "no operator pod found for app.kubernetes.io/component") | ||
| return true | ||
| } | ||
|
|
||
| func validateOperatorCustomLabelDefaultContainer() bool { | ||
| pods, err := KubeClient.CoreV1().Pods(operatorNsName).List(context.Background(), metav1.ListOptions{LabelSelector: "kubectl.kubernetes.io/default-container=manager"}) | ||
| ExpectWithOffset(2, err).ToNot(HaveOccurred(), "failed to get operator pods by label default-container") | ||
| ExpectWithOffset(2, len(pods.Items)).ToNot(BeZero(), "no operator pod found for kubectl.kubernetes.io/default-container") | ||
| return true | ||
| } | ||
| func isTainted(node *corev1.Node) bool { | ||
| medik8sDrainTaint := corev1.Taint{ | ||
| Key: "medik8s.io/drain", | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC the PR introduces 3 new labels while this function looks for the existence of only one of them. See also K8s recommended labels .
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I will add the new labels into thse e2e test.
Regard k8s recommended labels I over this doc and I think that all the relevant labels was added. Thank you for introducing me with these k8s convention