Skip to content

Commit

Permalink
Merge pull request #325 from replicatedhq/feat/rke3-k3s-anaylzer
Browse files Browse the repository at this point in the history
feat(analyzer): rke2 and k3s distro support
  • Loading branch information
Dan Stough authored Feb 19, 2021
2 parents 617e0d5 + c26824a commit 7647c03
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
7 changes: 6 additions & 1 deletion examples/preflight/sample-preflight.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,18 @@ spec:
- pass:
when: "== aks"
message: AKS is a supported distribution
# Will be supported in the future
- pass:
when: "== kurl"
message: KURL is a supported distribution
- pass:
when: "== digitalocean"
message: DigitalOcean is a supported distribution
- pass:
when: "== rke2"
message: RKE2 is a supported distribution
- pass:
when: "== k3s"
message: K3S is a supported distribution
- warn:
message: Unable to determine the distribution of Kubernetes
- nodeResources:
Expand Down
27 changes: 27 additions & 0 deletions pkg/analyze/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type providers struct {
aks bool
ibm bool
minikube bool
rke2 bool
k3s bool
}

type Provider int
Expand All @@ -38,6 +40,8 @@ const (
aks Provider = iota
ibm Provider = iota
minikube Provider = iota
rke2 Provider = iota
k3s Provider = iota
)

func CheckOpenShift(foundProviders *providers, apiResources []*metav1.APIResourceList, provider string) string {
Expand Down Expand Up @@ -77,6 +81,21 @@ func ParseNodesForProviders(nodes []corev1.Node) (providers, string) {
foundProviders.minikube = true
stringProvider = "minikube"
}
if k == "node.kubernetes.io/instance-type" && v == "k3s" {
foundProviders.k3s = true
stringProvider = "k3s"
}
if k == "beta.kubernetes.io/instance-type" && v == "k3s" {
foundProviders.k3s = true
stringProvider = "k3s"
}
}

for k := range node.ObjectMeta.Annotations {
if k == "rke2.io/node-args" {
foundProviders.rke2 = true
stringProvider = "rke2"
}
}

if node.Status.NodeInfo.OSImage == "Docker Desktop" {
Expand Down Expand Up @@ -270,6 +289,10 @@ func compareDistributionConditionalToActual(conditional string, actual providers
isMatch = actual.ibm
case minikube:
isMatch = actual.minikube
case rke2:
isMatch = actual.rke2
case k3s:
isMatch = actual.k3s
}

switch parts[0] {
Expand Down Expand Up @@ -304,6 +327,10 @@ func mustNormalizeDistributionName(raw string) Provider {
return ibm
case "minikube":
return minikube
case "rke2":
return rke2
case "k3s":
return k3s
}

return unknown
Expand Down

0 comments on commit 7647c03

Please sign in to comment.