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

Fetching dynamic kubeconfig #47

Merged
merged 18 commits into from
Oct 1, 2023

Conversation

akgalwas
Copy link
Contributor

Description

Changes proposed in this pull request:

  • KubeconfigProvider implemented
  • KubeconfigProvider initialized on application startup

Related issue(s)

@kyma-bot kyma-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 22, 2023
@kyma-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kyma-bot kyma-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 22, 2023
@akgalwas akgalwas marked this pull request as ready for review September 22, 2023 10:07
@akgalwas akgalwas requested a review from a team as a code owner September 22, 2023 10:07
cmd/main.go Outdated Show resolved Hide resolved
cmd/main.go Outdated Show resolved Hide resolved
@akgalwas akgalwas changed the title [WIP] Fetching dynamic kubeconfig Fetching dynamic kubeconfig Sep 26, 2023
@kyma-bot kyma-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 26, 2023
@@ -19,6 +19,8 @@ spec:
- /manager
args:
- --gardener-kubeconfig-path=/gardener/credentials/kubeconfig
- --gardener-project-name=kyma-dev
Copy link
Member

Choose a reason for hiding this comment

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

Should we already capture somewhere (maybe in some issue or documentation) that this should be overridden for other environments?

@Disper
Copy link
Member

Disper commented Sep 29, 2023

I was unable to test that successfully.
After applying the following sample CR:

apiVersion: infrastructuremanager.kyma-project.io/v1
kind: GardenerCluster
metadata:
  labels:
    kyma-project.io/instance-id: instance-id
    kyma-project.io/runtime-id: md-im3
    kyma-project.io/broker-plan-id: plan-id
    kyma-project.io/broker-plan-name: plan-name
    kyma-project.io/global-account-id: global-account-id
    kyma-project.io/subaccount-id: subAccount-id
    kyma-project.io/shoot-name: md-im3
    kyma-project.io/region: region
    operator.kyma-project.io/kyma-name: kymaName
  name: md-im3
  namespace: kcp-system
spec:
  shoot:
    name: md-im3
  kubeconfig:
    secret:
      name: kubeconfig-md-im3
      namespace: kcp-system
      key: "config"

I'm getting

2023-09-29T06:30:44Z    ERROR   Reconciler error        {"controller": "gardenercluster", "controllerGroup": "infrastructuremanager.kyma-project.io", "controllerKind": "GardenerCluster", "GardenerCluster": {"name":"md-im3","namespace":"kcp-system"}, "namespace": "kcp-system", "name": "md-im3", "reconcileID": "027f9eac-5c41-426b-944d-a41b1bc5b274", "error": "failed to get shoot: Get \"https://api.canary.gardener.cloud.sap/apis/core.gardener.cloud/v1beta1/namespaces/garden-frog-dev/shoots/md-im3\": getting credentials: exec: executable kubectl not found", "errorVerbose": "Get \"https://api.canary.gardener.cloud.sap/apis/core.gardener.cloud/v1beta1/namespaces/garden-frog-dev/shoots/md-im3\": getting credentials: exec: executable kubectl not found\nfailed to get shoot\ngithub.com/kyma-project/infrastructure-manager/internal/gardener.KubeconfigProvider.Fetch\n\t/workspace/internal/gardener/KubeConfigProvider.go:44\ngithub.com/kyma-project/infrastructure-manager/internal/controller.(*GardenerClusterController).newSecret\n\t/workspace/internal/controller/gardener_cluster_controller.go:183\ngithub.com/kyma-project/infrastructure-manager/internal/controller.(*GardenerClusterController).createSecret\n\t/workspace/internal/controller/gardener_cluster_controller.go:166\ngithub.com/kyma-project/infrastructure-manager/internal/controller.(*GardenerClusterController).Reconcile\n\t/workspace/internal/controller/gardener_cluster_controller.go:107\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.2/pkg/internal/controller/controller.go:118\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.2/pkg/internal/controller/controller.go:314\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.2/pkg/internal/controller/controller.go:265\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.2/pkg/internal/controller/controller.go:226\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1598"}
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.2/pkg/internal/controller/controller.go:324
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.2/pkg/internal/controller/controller.go:265
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
        /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.15.2/pkg/internal/controller/controller.go:226

Tested on

  • image: europe-docker.pkg.dev/kyma-project/dev/infrastructure-manager:PR-47
  • k8s clusters 1.27 & 1.26

By

  • Downloading either static or dynamic kubeconfig
  • running make deploy, make gardener-secret-deploy, kubectl apply -f config/samples/infrastructuremanager_v1_gardenercluster.yaml
  • Editing deployment to use mentioned previously image

@Disper
Copy link
Member

Disper commented Sep 29, 2023

I've had a screen sharing session with @akgalwas where I've seen that this feature works. I still don't know what is causing the issue I've mentioned in the previous comment, possibly some inconsistencies with the manifest generated via kustomize or some tooling that I use like kubectl.

@Disper Disper changed the title Fetching dynamic kubeconfig [WiP] Fetching dynamic kubeconfig Sep 29, 2023
@kyma-bot kyma-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 29, 2023
Copy link
Member

@Disper Disper left a comment

Choose a reason for hiding this comment

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

I'm giving an approval (see the previous comment) however I've didn't managed to have a closer look too see if there would be a good way to cover this with automated tests. @akgalwas Could you maybe consult other frog if there would be some nice way to introduce some automated test, or to make sure that we have a follow-up for that?

I've set the PR to [WiP] so it won't be merged automatically before you look at this comment but I'm also leaving an approval.

@kyma-bot kyma-bot added the lgtm Looks good to me! label Sep 29, 2023
@akgalwas akgalwas changed the title [WiP] Fetching dynamic kubeconfig Fetching dynamic kubeconfig Oct 1, 2023
@kyma-bot kyma-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 1, 2023
@kyma-bot kyma-bot merged commit 9cff167 into kyma-project:main Oct 1, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Looks good to me! size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants