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

SKS-1701: Filter ECP IP when using kubectl get elfmachine #137

Merged
merged 2 commits into from
Aug 16, 2023

Conversation

haijianyang
Copy link
Contributor

@haijianyang haijianyang commented Aug 16, 2023

问题

通过 kubectl get elfmachine 的时候,会显示 ECP 的 fake IP.

解决

通过 JSONPath=".status.addresses[?(@.address!="240.255.0.1")].address 过滤 ECP IP,240.255.0.1 是 ECP 固定使用的 IP。

测试

  1. addresses: [] 为空

kubectl get elfmachine
image

kubectl get elfmachine haijian-test3-controlplane-b7cwh -o=jsonpath="{.status.addresses[*].address}"
image

  1. addresses: [{address: 240.255.0.1, type: InternalIP}]

kubectl get elfmachine (默认使用修改过的CRD column定义,会将ecp fake IP过滤掉)
image

kubectl get elfmachine haijian-test3-controlplane-b7cwh -o=jsonpath="{.status.addresses[*].address}"
image

  1. addresses: [{address: 240.255.0.1, type: InternalIP},{address: 10.255.3.60, type: InternalIP}]

kubectl get elfmachine
image

kubectl get elfmachine haijian-test3-controlplane-b7cwh -o=jsonpath="{.status.addresses[*].address}"
image (12)

@codecov
Copy link

codecov bot commented Aug 16, 2023

Codecov Report

Merging #137 (fcc9d71) into master (c329797) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #137   +/-   ##
=======================================
  Coverage   55.71%   55.71%           
=======================================
  Files          16       16           
  Lines        2728     2728           
=======================================
  Hits         1520     1520           
  Misses       1073     1073           
  Partials      135      135           

@@ -179,7 +179,7 @@ type ElfMachineStatus struct {
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="ElfMachine ready status"
//+kubebuilder:printcolumn:name="ProviderID",type="string",JSONPath=".spec.providerID",description="ElfMachine instance ID"
//+kubebuilder:printcolumn:name="IP",type="string",JSONPath=".status.addresses[0].address",description="IP address of the first network device of the virtual machine"
//+kubebuilder:printcolumn:name="IP",type="string",JSONPath=".status.addresses[?(@.address!=\"240.255.0.1\")].address",description="IP address of one of the virtual machine's network devices"
Copy link
Collaborator

Choose a reason for hiding this comment

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

改成:"IP addresses of the virtual machine"

Copy link
Collaborator

@jessehu jessehu Aug 16, 2023

Choose a reason for hiding this comment

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

PR中的测试结果并没有使用带filter的jsonpath

明白了,是有的。我补充下PR描述。

@haijianyang haijianyang merged commit d3ac289 into smartxworks:master Aug 16, 2023
3 checks passed
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