github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/kubeconfig/kubeconfig.go (about)

     1  package kubeconfig
     2  
     3  type kubeconfig struct {
     4  	APIVersion     string `yaml:"apiVersion"`
     5  	Kind           string `yaml:"kind"`
     6  	CurrentContext string `yaml:"current-context"`
     7  	Clusters       []struct {
     8  		Name    string `yaml:"name"`
     9  		Cluster struct {
    10  			CertificateAuthorityData string `yaml:"certificate-authority-data"`
    11  			Server                   string `yaml:"server"`
    12  		} `yaml:"cluster"`
    13  	} `yaml:"clusters"`
    14  	Contexts []struct {
    15  		Name    string `yaml:"name"`
    16  		Context struct {
    17  			Cluster string `yaml:"cluster"`
    18  			User    string `yaml:"user"`
    19  		} `yaml:"context"`
    20  	} `yaml:"contexts"`
    21  	Users []struct {
    22  		Name string                 `yaml:"name"`
    23  		User map[string]interface{} `yaml:"user"`
    24  	} `yaml:"users"`
    25  }
    26  
    27  const kubeconfigTemplate = `
    28  ---
    29  apiVersion: v1
    30  kind: Config
    31  current-context: {{ .ContextName }}
    32  clusters:
    33  - name: {{ .ContextName }}
    34    cluster:
    35      certificate-authority-data: {{ .CAData }}
    36      server: {{ .ServerURL }}
    37  contexts:
    38  - name: {{ .ContextName }}
    39    context:
    40      cluster: {{ .ContextName }}
    41      user: {{ .ContextName }}
    42  users:
    43  - name: {{ .ContextName }}
    44    user:
    45      exec:
    46        apiVersion: client.authentication.k8s.io/v1beta1
    47        args:
    48        - get-token
    49        - "--oidc-issuer-url={{ .OIDCIssuerURL }}"
    50        - "--oidc-client-id={{ .OIDCClientID }}"
    51        - "--oidc-extra-scope=email"
    52        - "--oidc-extra-scope=openid"
    53        command: kubectl-oidc_login
    54        installHint: |
    55          kubelogin plugin is required to proceed with authentication
    56          # Homebrew (macOS and Linux)
    57          brew install int128/kubelogin/kubelogin
    58  
    59          # Krew (macOS, Linux, Windows and ARM)
    60          kubectl krew install oidc-login
    61  
    62          # Chocolatey (Windows)
    63          choco install kubelogin
    64  `