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

kube-applier fails at version check when using kubectl v1.28+ #61

Closed
jathinjd opened this issue Sep 10, 2024 · 0 comments · Fixed by #62
Closed

kube-applier fails at version check when using kubectl v1.28+ #61

jathinjd opened this issue Sep 10, 2024 · 0 comments · Fixed by #62

Comments

@jathinjd
Copy link
Contributor

When CheckVersion executes at the beginning of the run, it expects the golang version to parse the output and determine the versions.

func (c *Client) CheckVersion() error {
args := []string{"kubectl", "version"}
if c.LogLevel > -1 {
args = append(args, fmt.Sprintf("-v=%d", c.LogLevel))
}
if c.Server != "" {
args = append(args, fmt.Sprintf("--kubeconfig=%s", c.kubeconfigFilePath))
}
stdout, err := exec.Command(args[0], args[1:]...).CombinedOutput()
output := strings.TrimSuffix(string(stdout), "\n")
if err != nil {
return fmt.Errorf("Error checking kubectl version: %v", output)
}
// Using regular expressions, parse for the Major and Minor version numbers for both client and server.
clientPattern := regexp.MustCompile("(?:Client Version: version.Info{Major:\"([0-9+]+)\", Minor:\"([0-9+]+)\")")
serverPattern := regexp.MustCompile("(?:Server Version: version.Info{Major:\"([0-9+]+)\", Minor:\"([0-9+]+)\")")
clientInfo := clientPattern.FindAllStringSubmatch(output, -1)
clientMajor := clientInfo[0][1]
clientMinor := clientInfo[0][2]
serverInfo := serverPattern.FindAllStringSubmatch(output, -1)
serverMajor := serverInfo[0][1]
serverMinor := serverInfo[0][2]
return isCompatible(clientMajor, clientMinor, serverMajor, serverMinor)
}

As of kubectl v1.28, the default output of kubectl version is what used to be for kubectl version --short.

After 1.28 upgrade:


2024/09/06 02:06:13 Output trimmed from kubectl version: Client Version: v1.28.13
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.28.11-gke.1260000

This causes kube-applier to fail with an index out of range error.

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 a pull request may close this issue.

1 participant