Skip to content

Commit

Permalink
Merge pull request #205 from erhancagirici/azure-kubelogin-support
Browse files Browse the repository at this point in the history
azure AD identity support for AzureAD-enabled AKS clusters
  • Loading branch information
erhancagirici authored Dec 8, 2023
2 parents 2898887 + dc12e5a commit 6ba133b
Show file tree
Hide file tree
Showing 27 changed files with 947 additions and 785 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:

env:
# Common versions
GO_VERSION: '1.19.5'
GOLANGCI_VERSION: 'v1.50.1'
GO_VERSION: '1.20.12'
GOLANGCI_VERSION: 'v1.55.2'
DOCKER_BUILDX_VERSION: 'v0.8.2'

# Common users. We can't run a step 'if secrets.AWS_USR != ""' but we can run
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ GO_STATIC_PACKAGES = $(GO_PROJECT)/cmd/provider
GO_LDFLAGS += -X $(GO_PROJECT)/pkg/version.Version=$(VERSION)
GO_SUBDIRS += cmd pkg apis
GO111MODULE = on
GOLANGCILINT_VERSION = 1.55.2

-include build/makelib/golang.mk

# ====================================================================================
# Setup Kubernetes tools

UP_VERSION = v0.13.0
UP_VERSION = v0.21.0
UP_CHANNEL = stable
KIND_NODE_IMAGE_TAG ?= v1.24.0
USE_HELM3 = true
Expand Down
1 change: 0 additions & 1 deletion apis/release/v1alpha1/zz_generated.deepcopy.go

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

26 changes: 10 additions & 16 deletions apis/release/v1alpha1/zz_generated.managed.go

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

1 change: 0 additions & 1 deletion apis/release/v1beta1/zz_generated.deepcopy.go

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

26 changes: 10 additions & 16 deletions apis/release/v1beta1/zz_generated.managed.go

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

1 change: 0 additions & 1 deletion apis/v1alpha1/zz_generated.deepcopy.go

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

4 changes: 3 additions & 1 deletion apis/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ type IdentityType string
// Supported identity types.
const (
IdentityTypeGoogleApplicationCredentials = "GoogleApplicationCredentials"

IdentityTypeAzureServicePrincipalCredentials = "AzureServicePrincipalCredentials"
)

// Identity used to authenticate.
type Identity struct {
// Type of identity.
// +kubebuilder:validation:Enum=GoogleApplicationCredentials
// +kubebuilder:validation:Enum=GoogleApplicationCredentials;AzureServicePrincipalCredentials
Type IdentityType `json:"type"`

ProviderCredentials `json:",inline"`
Expand Down
1 change: 0 additions & 1 deletion apis/v1beta1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion build
9 changes: 8 additions & 1 deletion cmd/provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ limitations under the License.
package main

import (
"io"
"os"
"path/filepath"
"time"

"sigs.k8s.io/controller-runtime/pkg/cache"

"github.com/crossplane/crossplane-runtime/pkg/controller"
"github.com/crossplane/crossplane-runtime/pkg/feature"
"github.com/crossplane/crossplane-runtime/pkg/ratelimiter"
Expand Down Expand Up @@ -56,6 +59,8 @@ func main() {

zl := zap.New(zap.UseDevMode(*debug), UseISO8601())
log := logging.NewLogrLogger(zl.WithName("provider-helm"))
// explicitly provide a no-op logger by default, otherwise controller-runtime gives a warning
ctrl.SetLogger(zap.New(zap.WriteTo(io.Discard)))
if *debug {
// The controller-runtime runs with a no-op logger by default. It is
// *very* verbose even at info level, so we only provide it a real
Expand All @@ -67,7 +72,9 @@ func main() {
kingpin.FatalIfError(err, "Cannot get API server rest config")

mgr, err := ctrl.NewManager(ratelimiter.LimitRESTConfig(cfg, *maxReconcileRate), ctrl.Options{
SyncPeriod: syncInterval,
Cache: cache.Options{
SyncPeriod: syncInterval,
},

// controller-runtime uses both ConfigMaps and Leases for leader
// election by default. Leases expire after 15 seconds, with a
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: helm.crossplane.io/v1beta1
kind: ProviderConfig
metadata:
name: helm-provider
spec:
credentials:
source: Secret
secretRef:
name: cluster-config
namespace: crossplane-system
key: kubeconfig
identity:
type: AzureServicePrincipalCredentials
source: Secret
secretRef:
name: azure-credentials
namespace: crossplane-system
key: credentials.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: helm.crossplane.io/v1beta1
kind: ProviderConfig
metadata:
name: helm-provider
spec:
credentials:
source: Secret
secretRef:
name: cluster-config
namespace: crossplane-system
key: kubeconfig
identity:
type: GoogleApplicationCredentials
source: Secret
secretRef:
name: gcp-credentials
namespace: crossplane-system
key: credentials.json
2 changes: 1 addition & 1 deletion examples/provider-config/provider-config-with-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ spec:
# secretRef:
# name: gcp-credentials
# namespace: crossplane-system
# key: credentials.json
# key: credentials.json
Loading

0 comments on commit 6ba133b

Please sign in to comment.