Skip to content

Commit ab7f50d

Browse files
authored
improve detection of tanzu clusters (#1769)
1 parent cbb22e2 commit ab7f50d

File tree

4 files changed

+70
-13
lines changed

4 files changed

+70
-13
lines changed

examples/sdk/helm-template/go.mod

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ replace github.com/replicatedhq/troubleshoot v0.0.0 => ../../../
1111

1212
require (
1313
github.com/replicatedhq/troubleshoot v0.0.0
14-
helm.sh/helm/v3 v3.17.1
14+
helm.sh/helm/v3 v3.17.2
1515
sigs.k8s.io/yaml v1.4.0
1616
)
1717

@@ -47,30 +47,30 @@ require (
4747
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
4848
github.com/pkg/errors v0.9.1 // indirect
4949
github.com/shopspring/decimal v1.4.0 // indirect
50-
github.com/spf13/cast v1.7.0 // indirect
50+
github.com/spf13/cast v1.7.1 // indirect
5151
github.com/x448/float16 v0.8.4 // indirect
5252
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
5353
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
5454
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
55-
golang.org/x/crypto v0.35.0 // indirect
56-
golang.org/x/net v0.36.0 // indirect
55+
golang.org/x/crypto v0.36.0 // indirect
56+
golang.org/x/net v0.38.0 // indirect
5757
golang.org/x/oauth2 v0.25.0 // indirect
58-
golang.org/x/sys v0.30.0 // indirect
59-
golang.org/x/term v0.29.0 // indirect
60-
golang.org/x/text v0.22.0 // indirect
61-
golang.org/x/time v0.7.0 // indirect
58+
golang.org/x/sys v0.31.0 // indirect
59+
golang.org/x/term v0.30.0 // indirect
60+
golang.org/x/text v0.23.0 // indirect
61+
golang.org/x/time v0.8.0 // indirect
6262
google.golang.org/protobuf v1.36.2 // indirect
6363
gopkg.in/inf.v0 v0.9.1 // indirect
6464
gopkg.in/yaml.v2 v2.4.0 // indirect
6565
gopkg.in/yaml.v3 v3.0.1 // indirect
66-
k8s.io/api v0.32.2 // indirect
67-
k8s.io/apiextensions-apiserver v0.32.2 // indirect
68-
k8s.io/apimachinery v0.32.2 // indirect
69-
k8s.io/client-go v0.32.2 // indirect
66+
k8s.io/api v0.32.3 // indirect
67+
k8s.io/apiextensions-apiserver v0.32.3 // indirect
68+
k8s.io/apimachinery v0.32.3 // indirect
69+
k8s.io/client-go v0.32.3 // indirect
7070
k8s.io/klog/v2 v2.130.1 // indirect
7171
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
7272
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
73-
sigs.k8s.io/controller-runtime v0.20.2 // indirect
73+
sigs.k8s.io/controller-runtime v0.20.4 // indirect
7474
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
7575
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
7676
)

examples/sdk/helm-template/go.sum

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp
9090
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
9191
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
9292
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
93+
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
9394
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
9495
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
9596
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -112,6 +113,7 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
112113
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
113114
golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
114115
golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
116+
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
115117
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
116118
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
117119
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -120,6 +122,7 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
120122
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
121123
golang.org/x/net v0.36.0 h1:vWF2fRbw4qslQsQzgFqZff+BItCvGFQqKzKIzx1rmoA=
122124
golang.org/x/net v0.36.0/go.mod h1:bFmbeoIPfrw4sMHNhb4J9f6+tPziuGjq7Jk/38fxi1I=
125+
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
123126
golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70=
124127
golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
125128
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -130,14 +133,18 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
130133
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
131134
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
132135
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
136+
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
133137
golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
134138
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
139+
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
135140
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
136141
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
137142
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
138143
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
144+
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
139145
golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ=
140146
golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
147+
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
141148
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
142149
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
143150
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
@@ -163,14 +170,19 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
163170
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
164171
helm.sh/helm/v3 v3.17.1 h1:gzVoAD+qVuoJU6KDMSAeo0xRJ6N1znRxz3wyuXRmJDk=
165172
helm.sh/helm/v3 v3.17.1/go.mod h1:nvreuhuR+j78NkQcLC3TYoprCKStLyw5P4T7E5itv2w=
173+
helm.sh/helm/v3 v3.17.2/go.mod h1:+uJKMH/UiMzZQOALR3XUf3BLIoczI2RKKD6bMhPh4G8=
166174
k8s.io/api v0.32.2 h1:bZrMLEkgizC24G9eViHGOPbW+aRo9duEISRIJKfdJuw=
167175
k8s.io/api v0.32.2/go.mod h1:hKlhk4x1sJyYnHENsrdCWw31FEmCijNGPJO5WzHiJ6Y=
176+
k8s.io/api v0.32.3/go.mod h1:2wEDTXADtm/HA7CCMD8D8bK4yuBUptzaRhYcYEEYA3k=
168177
k8s.io/apiextensions-apiserver v0.32.2 h1:2YMk285jWMk2188V2AERy5yDwBYrjgWYggscghPCvV4=
169178
k8s.io/apiextensions-apiserver v0.32.2/go.mod h1:GPwf8sph7YlJT3H6aKUWtd0E+oyShk/YHWQHf/OOgCA=
179+
k8s.io/apiextensions-apiserver v0.32.3/go.mod h1:8YwcvVRMVzw0r1Stc7XfGAzB/SIVLunqApySV5V7Dss=
170180
k8s.io/apimachinery v0.32.2 h1:yoQBR9ZGkA6Rgmhbp/yuT9/g+4lxtsGYwW6dR6BDPLQ=
171181
k8s.io/apimachinery v0.32.2/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
182+
k8s.io/apimachinery v0.32.3/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
172183
k8s.io/client-go v0.32.2 h1:4dYCD4Nz+9RApM2b/3BtVvBHw54QjMFUl1OLcJG5yOA=
173184
k8s.io/client-go v0.32.2/go.mod h1:fpZ4oJXclZ3r2nDOv+Ux3XcJutfrwjKTCHz2H3sww94=
185+
k8s.io/client-go v0.32.3/go.mod h1:3v0+3k4IcT9bXTc4V2rt+d2ZPPG700Xy6Oi0Gdl2PaY=
174186
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
175187
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
176188
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y=
@@ -179,6 +191,7 @@ k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6J
179191
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
180192
sigs.k8s.io/controller-runtime v0.20.2 h1:/439OZVxoEc02psi1h4QO3bHzTgu49bb347Xp4gW1pc=
181193
sigs.k8s.io/controller-runtime v0.20.2/go.mod h1:xg2XB0K5ShQzAgsoujxuKN4LNXR2LfwwHsPj7Iaw+XY=
194+
sigs.k8s.io/controller-runtime v0.20.4/go.mod h1:xg2XB0K5ShQzAgsoujxuKN4LNXR2LfwwHsPj7Iaw+XY=
182195
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8=
183196
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo=
184197
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA=

pkg/analyze/distribution.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ func ParseNodesForProviders(nodes []corev1.Node) (providers, string) {
149149
foundProviders.embeddedCluster = true
150150
stringProvider = "embedded-cluster"
151151
}
152+
153+
if k == "run.tanzu.vmware.com/kubernetesDistributionVersion" {
154+
foundProviders.tanzu = true
155+
stringProvider = "tanzu"
156+
}
152157
}
153158

154159
for k := range node.ObjectMeta.Annotations {

pkg/analyze/distribution_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,45 @@ func TestParseNodesForProviders(t *testing.T) {
201201
wantProviders: providers{embeddedCluster: true, k0s: true},
202202
wantProviderString: "embedded-cluster",
203203
},
204+
{
205+
name: "tanzu",
206+
nodes: []corev1.Node{
207+
{
208+
ObjectMeta: metav1.ObjectMeta{
209+
Name: "t-node",
210+
Annotations: map[string]string{
211+
"cluster.x-k8s.io/cluster-name": "test-cluster-name",
212+
"cluster.x-k8s.io/cluster-namespace": "dev",
213+
"cluster.x-k8s.io/labels-from-machine": "machinelabel",
214+
"cluster.x-k8s.io/machine": "machinename",
215+
"cluster.x-k8s.io/owner-kind": "KubeadmControlPlane",
216+
"cluster.x-k8s.io/owner-name": "owner-name",
217+
"csi.volume.kubernetes.io/nodeid": "{\"csi.vsphere.vmware.com\":\"test-node-id\"}",
218+
"kubeadm.alpha.kubernetes.io/cri-socket": "unix:///var/run/containerd/containerd.sock",
219+
"node.alpha.kubernetes.io/ttl": "0",
220+
"volumes.kubernetes.io/controller-managed-attach-detach": "true",
221+
"creationTimestamp": "2025-02-19T09:16:51Z",
222+
},
223+
Labels: map[string]string{
224+
"beta.kubernetes.io/arch": "amd64",
225+
"beta.kubernetes.io/os": "linux",
226+
"failure-domain.beta.kubernetes.io/zone": "tanzu-zone-1",
227+
"kubernetes.io/arch": "amd64",
228+
"kubernetes.io/hostname": "machinename",
229+
"kubernetes.io/os": "linux",
230+
"node-role.kubernetes.io/control-plane": "",
231+
"node.cluster.x-k8s.io/esxi-host": "esxi-host",
232+
"node.kubernetes.io/exclude-from-external-load-balancers": "",
233+
"run.tanzu.vmware.com/kubernetesDistributionVersion": "v1.27.11---vmware.1-fips.1-tkg.2",
234+
"run.tanzu.vmware.com/tkr": "v1.27.11---vmware.1-fips.1-tkg.2",
235+
"topology.kubernetes.io/zone": "tanzu-zone-1",
236+
},
237+
},
238+
},
239+
},
240+
wantProviders: providers{tanzu: true},
241+
wantProviderString: "tanzu",
242+
},
204243
}
205244
for _, tt := range tests {
206245
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)