Skip to content

Commit

Permalink
Merge pull request #252 from dntosas/feat/eks-support
Browse files Browse the repository at this point in the history
feat: add support for EKS cluster secrets
  • Loading branch information
dntosas committed Feb 20, 2024
2 parents 855f175 + eb318c5 commit 6fc9ad9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion charts/capi2argo-cluster-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
appVersion: 0.1.14
appVersion: 0.2.0
description: Capi-2-Argo Cluster Operator (CACO) converts ClusterAPI Cluster credentials into ArgoCD Cluster definitions and keep them synchronized.
home: https://github.com/dntosas/capi2argo-cluster-operator
keywords:
Expand Down
2 changes: 1 addition & 1 deletion charts/capi2argo-cluster-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ replicaCount: 1
image:
registry: ghcr.io
repository: dntosas/capi2argo-cluster-operator
tag: v0.1.14
tag: v0.2.0
pullPolicy: Always
pullSecrets: []

Expand Down
2 changes: 2 additions & 0 deletions controllers/argo_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type ArgoCluster struct {
// ArgoConfig represents Argo Cluster.JSON.config
type ArgoConfig struct {
TLSClientConfig ArgoTLS `json:"tlsClientConfig"`
BearerToken string `json:"bearerToken"`
}

// ArgoTLS represents Argo Cluster.JSON.config.tlsClientConfig
Expand Down Expand Up @@ -81,6 +82,7 @@ func NewArgoCluster(c *CapiCluster, s *corev1.Secret, cluster *clusterv1.Cluster
},
TakeAlongLabels: takeAlongLabels,
ClusterConfig: ArgoConfig{
BearerToken: c.KubeConfig.Users[0].User.Token,
TLSClientConfig: ArgoTLS{
CaData: c.KubeConfig.Clusters[0].Cluster.CaData,
CertData: c.KubeConfig.Users[0].User.CertData,
Expand Down
3 changes: 2 additions & 1 deletion controllers/capi_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type User struct {
type UserInfo struct {
CertData string `yaml:"client-certificate-data"`
KeyData string `yaml:"client-key-data"`
Token string `yaml:"token"`
}

// NewCapiCluster returns an empty CapiCluster type.
Expand Down Expand Up @@ -85,5 +86,5 @@ func ValidateCapiSecret(s *corev1.Secret) error {

// ValidateCapiNaming validates CAPI kubeconfig naming convention.
func ValidateCapiNaming(n types.NamespacedName) bool {
return strings.HasSuffix(n.Name, "-kubeconfig")
return strings.HasSuffix(n.Name, "-kubeconfig") && !strings.HasSuffix(n.Name, "-user-kubeconfig")
}
11 changes: 11 additions & 0 deletions tests/capi-kubeconfig-eks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Config
clusters:
- cluster:
certificate-authority-data: test
server: https://test.gr7.eu-west-1.eks.amazonaws.com
name: test-cluster
users:
- name: test-cluster-capi-admin
user:
token: test

0 comments on commit 6fc9ad9

Please sign in to comment.