Skip to content

Add kube config generator for clusters#74

Merged
shydefoo merged 10 commits into
mainfrom
kube-config-generator
Jan 17, 2023
Merged

Add kube config generator for clusters#74
shydefoo merged 10 commits into
mainfrom
kube-config-generator

Conversation

@shydefoo
Copy link
Copy Markdown
Collaborator

This PR adds common code to generate k8s rest.Config that will be used in Merlin and Turing.

@shydefoo shydefoo force-pushed the kube-config-generator branch from d7b933b to 230043a Compare January 12, 2023 12:44
Comment thread api/pkg/cluster/cluster.go Outdated
Comment thread api/pkg/cluster/cluster_test.go Outdated
@shydefoo
Copy link
Copy Markdown
Collaborator Author

Note: Interface name and methods have been renamed to improve readability

Comment thread api/pkg/cluster/cluster_test.go Outdated
Copy link
Copy Markdown
Collaborator

@krithika369 krithika369 left a comment

Choose a reason for hiding this comment

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

Left one small comment, the rest LGTM. Thanks, @shydefoo !

@shydefoo shydefoo merged commit 05ede13 into main Jan 17, 2023
@shydefoo shydefoo deleted the kube-config-generator branch January 17, 2023 02:47
shydefoo added a commit to caraml-dev/merlin that referenced this pull request Feb 1, 2023
<!--  Thanks for sending a pull request!  Here are some tips for you:

1. Run unit tests and ensure that they are passing
2. If your change introduces any API changes, make sure to update the
e2e tests
3. Make sure documentation is updated for your PR!

-->

**What this PR does / why we need it**:
* This PR removes the dependency on vault. Clusters are accessed via
configuration passed at runtime.
* caraml-dev/mlp#74 should be merged first before
merging
* The changes related to deprecating vault dependencies are in these
dirs:
  * `cluster`
  * `cmd/api`
  * `config`
  * `istio`
  * `charts/merlin`
* The `gke-gcloud-auth-plugin` binary is added to the Dockerfile, this
is allow access to GKE clusters without providing static credentials.

### Setup changes
To configure access to model clusters, the `environments.yaml` has a new
field `k8s_config`:
```yaml
- name: id-dev
  ...
  k8s_config:
    name: id-dev
    cluster:
      server: id-dev.k8s-cluster
      insecure-skip-tls-verify: true
    user:
      exec:
        apiVersion: client.authentication.k8s.io/v1beta1
        command: gke-gcloud-auth-plugin
        interactiveMode: IfAvailable
        provideClusterInfo: true
```
The cluster and user fields correspond to the
[Cluster](https://pkg.go.dev/k8s.io/client-go/tools/clientcmd/api/v1#Cluster)
struct and
[AuthInfo](https://pkg.go.dev/k8s.io/client-go/tools/clientcmd/api/v1#AuthInfo)
struct defined in client-go clientcmd/api/v1 package.

To configure access to the Imagebuilder cluster, there is a new
environment variable `IMG_BUILDER_K8S_CONFIG` which takes a json object
of the same format as what's passed into the `k8s_config` field in
`environments.yaml`:
```
IMG_BUILDER_K8S_CONFIG='{"name":"id-dev","cluster":{"server":"id-dev.k8s.cluster","insecure-skip-tls-verify":true},"user":{"exec":{"apiVersion":"client.authentication.k8s.io/v1beta1","command":"gke-gcloud-auth-plugin","interactiveMode":"IfAvailable","provideClusterInfo":true}}}'
```

**Does this PR introduce a user-facing change?**:
<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required. Enter your extended release note in
the block below.
If the PR requires additional action from users switching to the new
release, include the string "action required".

For more information about release notes, see kubernetes' guide here:
http://git.k8s.io/community/contributors/guide/release-notes.md
-->
No

```release-note
NONE
```

**Checklist**

- [x] Added unit test, integration, and/or e2e tests
- [x] Tested locally
- [x] Updated documentation
- [ ] Update Swagger spec if the PR introduce API changes
- [ ] Regenerated Golang and Python client if the PR introduce API
changes
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 this pull request may close these issues.

3 participants