Skip to content

Commit

Permalink
Merge pull request #66 from stevendborrelli/kubeconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterMX authored Sep 6, 2023
2 parents 520e586 + 991d2e4 commit d456a7b
Show file tree
Hide file tree
Showing 8 changed files with 348 additions and 98 deletions.
33 changes: 28 additions & 5 deletions apis/cluster/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ import (

// ClusterParameters define the desired state of an ArgoCD Cluster
type ClusterParameters struct {
// Server is the API server URL of the Kubernetes cluster
Server string `json:"server"`
// Name of the cluster. If omitted, will use the server address
Name string `json:"name"`
// Server is the API server URL of the Kubernetes cluster. Optional if using a kubeconfig
// +optional
Server *string `json:"server"`
// Name of the cluster. If omitted, will use the server address. Optional if using a kubeconfig
// +optional
Name *string `json:"name"`
// Config holds cluster information for connecting to a cluster
Config ClusterConfig `json:"config"`
// Holds list of namespaces which are accessible in that cluster. Cluster level resources will be ignored if namespace list is not empty.
Expand Down Expand Up @@ -59,13 +61,20 @@ type ClusterConfig struct {
// +optional
BearerTokenSecretRef *SecretReference `json:"bearerTokenSecretRef,omitempty"`
// TLSClientConfig contains settings to enable transport layer security
TLSClientConfig `json:"tlsClientConfig"`
// +optional
TLSClientConfig *TLSClientConfig `json:"tlsClientConfig"`
// AWSAuthConfig contains IAM authentication configuration
// +optional
AWSAuthConfig *AWSAuthConfig `json:"awsAuthConfig,omitempty"`
// ExecProviderConfig contains configuration for an exec provider
// +optional
ExecProviderConfig *ExecProviderConfig `json:"execProviderConfig,omitempty"`
// KubeconfigSecretRef contains a reference to a Kubernetes secret entry that
// contains a raw kubeconfig in YAML or JSON.
// See https://kubernetes.io/docs/reference/config-api/kubeconfig.v1/ for more
// info about Kubeconfigs
// +optional
KubeconfigSecretRef *SecretReference `json:"kubeconfigSecretRef,omitempty"`
}

// SecretReference holds the reference to a Kubernetes secret
Expand All @@ -80,6 +89,17 @@ type SecretReference struct {
Key string `json:"key"`
}

// KubeconfigObservation holds the status of a referenced Kubeconfig
type KubeconfigObservation struct {
Secret SecretObservation `json:"secret,omitempty"`
}

// SecretObservation observes a secret
type SecretObservation struct {
// ResourceVersion tracks the meta1.ResourceVersion of an Object
ResourceVersion string `json:"resourceVersion,omitempty"`
}

// ClusterInfo holds information about cluster cache and state
type ClusterInfo struct {
// ConnectionState contains information about the connection to the cluster
Expand Down Expand Up @@ -176,6 +196,9 @@ type ClusterObservation struct {
// ClusterInfo holds information about cluster cache and state
// +optional
ClusterInfo ClusterInfo `json:"connectionState,omitempty"`
// Kubeconfig tracks changes to a Kubeconfig secret
// +optional
Kubeconfig *KubeconfigObservation `json:"kubeconfig,omitempty"`
}

// A ClusterSpec defines the desired state of an ArgoCD Cluster.
Expand Down
57 changes: 56 additions & 1 deletion apis/cluster/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions examples/application/application-kubeconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
# Example using a KubeconfigSecretRef
apiVersion: applications.argocd.crossplane.io/v1alpha1
kind: Application
metadata:
name: example-application-kubeconfig
spec:
providerConfigRef:
name: argocd-provider
forProvider:
destination:
namespace: default
name: example-cluster-kubeconfig
project: default
source:
repoURL: https://github.com/stefanprodan/podinfo/
path: charts/podinfo
targetRevision: HEAD
15 changes: 15 additions & 0 deletions examples/cluster/cluster-kubeconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
apiVersion: cluster.argocd.crossplane.io/v1alpha1
kind: Cluster
metadata:
name: example-cluster-kubeconfig
spec:
forProvider:
name: example-cluster-kubeconfig
config:
kubeconfigSecretRef:
name: cluster-conn
namespace: crossplane-system
key: kubeconfig
providerConfigRef:
name: argocd-provider
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ require (
gopkg.in/alecthomas/kingpin.v2 v2.2.6
k8s.io/api v0.27.1
k8s.io/apimachinery v0.27.1
k8s.io/client-go v0.26.3
k8s.io/utils v0.0.0-20230209194617-a36077c30491
sigs.k8s.io/controller-runtime v0.14.6
sigs.k8s.io/controller-tools v0.12.0
)
Expand Down Expand Up @@ -156,15 +158,13 @@ require (
k8s.io/apiextensions-apiserver v0.27.1 // indirect
k8s.io/apiserver v0.26.3 // indirect
k8s.io/cli-runtime v0.26.3 // indirect
k8s.io/client-go v0.26.3 // indirect
k8s.io/component-base v0.26.3 // indirect
k8s.io/component-helpers v0.26.3 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-aggregator v0.24.2 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/kubectl v0.24.2 // indirect
k8s.io/kubernetes v1.26.3 // indirect
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/api v0.12.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect
Expand Down
41 changes: 35 additions & 6 deletions package/crds/cluster.argocd.crossplane.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,26 @@ spec:
doesn't seem to be present
type: string
type: object
kubeconfigSecretRef:
description: KubeconfigSecretRef contains a reference to a
Kubernetes secret entry that contains a raw kubeconfig in
YAML or JSON. See https://kubernetes.io/docs/reference/config-api/kubeconfig.v1/
for more info about Kubeconfigs
properties:
key:
description: Key whose value will be used.
type: string
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- key
- name
- namespace
type: object
passwordSecretRef:
description: PasswordSecretRef contains a reference to a kubernetes
secret containing the Password
Expand Down Expand Up @@ -231,8 +251,6 @@ spec:
username:
description: Server requires Basic authentication
type: string
required:
- tlsClientConfig
type: object
labels:
additionalProperties:
Expand All @@ -241,7 +259,7 @@ spec:
type: object
name:
description: Name of the cluster. If omitted, will use the server
address
address. Optional if using a kubeconfig
type: string
namespaces:
description: Holds list of namespaces which are accessible in
Expand All @@ -256,7 +274,8 @@ spec:
entity
type: string
server:
description: Server is the API server URL of the Kubernetes cluster
description: Server is the API server URL of the Kubernetes cluster.
Optional if using a kubeconfig
type: string
shard:
description: Shard contains optional shard number. Calculated
Expand All @@ -265,8 +284,6 @@ spec:
type: integer
required:
- config
- name
- server
type: object
providerConfigRef:
default:
Expand Down Expand Up @@ -504,6 +521,18 @@ spec:
required:
- applicationsCount
type: object
kubeconfig:
description: Kubeconfig tracks changes to a Kubeconfig secret
properties:
secret:
description: SecretObservation observes a secret
properties:
resourceVersion:
description: ResourceVersion tracks the meta1.ResourceVersion
of an Object
type: string
type: object
type: object
type: object
conditions:
description: Conditions of the resource.
Expand Down
Loading

0 comments on commit d456a7b

Please sign in to comment.