diff --git a/charts/capi2argo-cluster-operator/Chart.yaml b/charts/capi2argo-cluster-operator/Chart.yaml index 91b678ef..f5942aef 100644 --- a/charts/capi2argo-cluster-operator/Chart.yaml +++ b/charts/capi2argo-cluster-operator/Chart.yaml @@ -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: diff --git a/charts/capi2argo-cluster-operator/values.yaml b/charts/capi2argo-cluster-operator/values.yaml index 585834a2..321717c4 100644 --- a/charts/capi2argo-cluster-operator/values.yaml +++ b/charts/capi2argo-cluster-operator/values.yaml @@ -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: [] diff --git a/controllers/argo_cluster.go b/controllers/argo_cluster.go index 459a6585..f08ecd73 100644 --- a/controllers/argo_cluster.go +++ b/controllers/argo_cluster.go @@ -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 @@ -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, diff --git a/controllers/capi_cluster.go b/controllers/capi_cluster.go index e6503aac..1598af28 100644 --- a/controllers/capi_cluster.go +++ b/controllers/capi_cluster.go @@ -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. @@ -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") } diff --git a/tests/capi-kubeconfig-eks.yaml b/tests/capi-kubeconfig-eks.yaml new file mode 100644 index 00000000..fb9e0001 --- /dev/null +++ b/tests/capi-kubeconfig-eks.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Config +clusters: +- cluster: + certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURCVENDQWUyZ0F3SUJBZ0lJRnpCL0N3c1hXOGd3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TkRBeU1qQXhNVEV6TWpsYUZ3MHpOREF5TVRjeE1URTRNamxhTUJVeApFekFSQmdOVkJBTVRDbXQxWW1WeWJtVjBaWE13Z2dFaU1BMEdDU3FHU0liM0RRRUJBUVVBQTRJQkR3QXdnZ0VLCkFvSUJBUURoejZDOThoY09EUTVSLzZFSHpKR2tGM1YxWklSTkFxc2tFYkQ1Uk5xWEh1SWN0ZXk5YW8ya1hMcFUKUTJieGt4NDVXU2gxY1VHd0QwK2tBRXhEd2tSYStqbTBVaFlRM09uSG9zMVB6RnJLUnI5VG1XTXByYWo3akl0YQp6b1ZzQXlKN0tPT2NqWldkSjNDU2k3NHdWVklyTFpmL2NtMHh3eERqaFpDajRxUnBUZXIwakIrbjJGczFxVU9uCnVsdERwUzlkV0JwTGVkNWRBRU5UZGF5c0V4TDFseUh0NzI0OGZHckMySW1IN0N4NDljWWpVUEh0SkR4Vm9IZGcKZjFGdUZ6WjRaWGl3Sm9mYXNRMlZYS2p0L0VzOXVqcTQ3cWovd1pUd0pKTjl5dVRmNmxCT2cwKytXam1ua1ZpMAp5MndTdVVwd1BVc1pDS2Q3UEZJdVhDZnlSKzNCQWdNQkFBR2pXVEJYTUE0R0ExVWREd0VCL3dRRUF3SUNwREFQCkJnTlZIUk1CQWY4RUJUQURBUUgvTUIwR0ExVWREZ1FXQkJTV1A0ckVKQy9sN3FnVGx2QndzZDRXckxJOENqQVYKQmdOVkhSRUVEakFNZ2dwcmRXSmxjbTVsZEdWek1BMEdDU3FHU0liM0RRRUJDd1VBQTRJQkFRQWVRUzF5T2pidAp1N1VNTU03U1BpdkEzeXRzS0pVbUw0ZTBmQjd0YzNaUVUwYjAyR0k4RUFRdGZoVGZxNW4yRUx5bEtJZTVXQW5DCmlPWWJha1QrSVJGQXJwR09YM2wxQkhmV0owUDN5UGxTQUYvbEpxc1FGRmdqTGJHbnFQWWhZWXQwTEp2THVOdDQKcXRDcndHMEdHZ05lUUkrYkpseFcwQmtZZHI2UmhHUEc1S0dqQWFQMlFhZ3hoTDVhNk9sUE5EVEQ4cFpweFhPNAo4UmVOS2lEanNTcVFYU0hXVTZCWms0K1F4VWdBM3I4S29yN3Jnb0JTOFpWVmR2NDhLdHAwRXZqUnRxQWdqc0FoCmFZc3NyeHVyV3VRaVpNUnJ6RXMwZU5SMjduUlhCN0g2ZTZPQURqbkNBZnBnMnA3bVJKSFJBUS9yRklCOXNScisKUDNuVVQrQnd4OE9iCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K + server: https://FCB6EDA3109F58343CAFE69A0EC5CAEF.gr7.eu-west-1.eks.amazonaws.com + name: test-managed-cluster +users: +- name: test-managed-cluster-capi-admin + user: + token: k8s-aws-v1.aHR0cHM6Ly9zdHMuZXUtd2VzdC0xLmFtYXpvbmF3cy5jb20vP0FjdGlvbj1HZXRDYWxsZXJJZGVudGl0eSZWZXJzaW9uPTIwMTEtMDYtMTUmWC1BbXotQWxnb3JpdGhtPUFXUzQ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