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

Why is kubeconfig needed during operator-sdk new #1625

Closed
pgerv12 opened this issue Jul 1, 2019 · 2 comments · Fixed by #1627
Closed

Why is kubeconfig needed during operator-sdk new #1625

pgerv12 opened this issue Jul 1, 2019 · 2 comments · Fixed by #1627
Assignees
Labels
language/helm Issue is related to a Helm operator project

Comments

@pgerv12
Copy link

pgerv12 commented Jul 1, 2019

Type of question

operator-sdk general context

Question

What did you do?
Running operator-sdk new fails because a kubeconfig cannot be found.

What did you expect to see?
Generation of Helm Operator files (Dockerfile, yamls, etc.)

What did you see instead? Under which circumstances?

INFO[0000] Creating new Helm operator 'instance-operator'. 
INFO[0000] Created helm-charts/instance  
Error: failed to get kubernetes config: could not locate a kubeconfig
Usage:
  operator-sdk new <project-name> [flags]

Flags:
      --api-version string          Kubernetes apiVersion and has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1) - used with "ansible" or "helm" types
      --dep-manager string          Dependency manager the new project will use (choices: "dep", "modules") (default "modules")
      --generate-playbook           Generate a playbook skeleton. (Only used for --type ansible)
      --header-file string          Path to file containing headers for generated Go files. Copied to hack/boilerplate.go.txt
      --helm-chart string           Initialize helm operator with existing helm chart (<URL>, <repo>/<name>, or local path)
      --helm-chart-repo string      Chart repository URL for the requested helm chart
      --helm-chart-version string   Specific version of the helm chart (default is latest version)
  -h, --help                        help for new
      --kind string                 Kubernetes CustomResourceDefintion kind. (e.g AppService) - used with "ansible" or "helm" types
      --skip-git-init               Do not init the directory as a git repository
      --type string                 Type of operator to initialize (choices: "go", "ansible" or "helm") (default "go")

Global Flags:
      --verbose   Enable verbose logging

Environment

  • operator-sdk version:

    0.8.1

  • Kubernetes version information:
    1.15.0

  • Kubernetes cluster kind:

Additional context
I understand needing a kubeconfig for testing with up but this shouldn't be needed for creating a new Operator. My use case is that I have Docker systems where I can build/publish images but is separate from my kubernetes cluster. While I may be able to find a work around with a fake K8s config, I think there should be an official solution.

@joelanford joelanford self-assigned this Jul 1, 2019
@joelanford joelanford added the language/helm Issue is related to a Helm operator project label Jul 1, 2019
@joelanford
Copy link
Member

@pgerv12 The reason the Helm operator project scaffolding using a kubeconfig is that it generates an RBAC role for the chart by rendering the default chart and then looking up the manifest resources using the Kubernetes discovery API.

Having said that, we have logic to handle generation errors by reverting to the default rules built into the SDK scaffolds. We could look into extending that logic to work in the case of a missing or broken kubeconfig as well.

clusterResourceRules, namespacedResourceRules, err := generateRoleRules(dc, chart)
if err != nil {
log.Warnf("Using default RBAC rules: failed to generate RBAC rules: %s", err)
roleScaffold.SkipDefaultRules = false
return roleScaffold, nil
}

@pgerv12
Copy link
Author

pgerv12 commented Jul 1, 2019

@joelanford Thanks for the quick reply. That makes sense now. My vote would be to throw out a warning and continue with defaults.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language/helm Issue is related to a Helm operator project
Projects
None yet
2 participants