Skip to content

Commit

Permalink
Merge pull request #170 from haarchri/feature/kubelogin-azure-ad-auth
Browse files Browse the repository at this point in the history
feat(kubelogin): add kubelogin azure ad auth
  • Loading branch information
turkenh committed Dec 29, 2023
2 parents 6bb6320 + 73d2e66 commit c8a78af
Show file tree
Hide file tree
Showing 15 changed files with 542 additions and 93 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.20.2'
GOLANGCI_VERSION: 'v1.51.2'
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
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ GO_TEST_PARALLEL := $(shell echo $$(( $(NPROCS) / 2 )))
GO_STATIC_PACKAGES = $(GO_PROJECT)/cmd/provider
GO_SUBDIRS += cmd internal apis
GO111MODULE = on
GOLANGCILINT_VERSION = 1.51.2
GOLANGCILINT_VERSION = 1.55.2
-include build/makelib/golang.mk

# ====================================================================================
# Setup Kubernetes tools
KIND_VERSION = v0.18.0
UP_VERSION = v0.17.0
UPTEST_VERSION = v0.5.0
UP_VERSION = v0.21.0
UPTEST_VERSION = v0.9.0
UP_CHANNEL = stable
USE_HELM3 = true
-include build/makelib/k8s_tools.mk
Expand Down Expand Up @@ -92,7 +92,7 @@ CROSSPLANE_NAMESPACE = crossplane-system
UPTEST_EXAMPLE_LIST ?= "examples/object/object.yaml"
uptest: $(UPTEST) $(KUBECTL) $(KUTTL)
@$(INFO) running automated tests
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) $(UPTEST) e2e "$(UPTEST_EXAMPLE_LIST)" --setup-script=cluster/test/setup.sh || $(FAIL)
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=${CROSSPLANE_NAMESPACE} $(UPTEST) e2e "$(UPTEST_EXAMPLE_LIST)" --setup-script=cluster/test/setup.sh || $(FAIL)
@$(OK) running automated tests

local-dev: controlplane.up
Expand Down
4 changes: 3 additions & 1 deletion apis/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,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
2 changes: 1 addition & 1 deletion build
3 changes: 3 additions & 0 deletions cmd/provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package main

import (
"io"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -52,6 +53,8 @@ func main() {

zl := zap.New(zap.UseDevMode(*debug), UseISO8601())
log := logging.NewLogrLogger(zl.WithName("provider-kubernetes"))
// 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 Down
8 changes: 0 additions & 8 deletions examples/provider/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,3 @@ spec:
namespace: crossplane-system
name: cluster-config
key: kubeconfig
# identity:
# type: GoogleApplicationCredentials
# source: Secret
# secretRef:
# name: gcp-credentials
# namespace: crossplane-system
# key: credentials.json

18 changes: 18 additions & 0 deletions examples/provider/provider-config-with-secret-azure-identity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: ProviderConfig
metadata:
name: kubernetes-provider
spec:
credentials:
source: Secret
secretRef:
namespace: crossplane-system
name: cluster-config
key: kubeconfig
identity:
type: AzureServicePrincipalCredentials
source: Secret
secretRef:
name: azure-credentials
namespace: crossplane-system
key: credentials.json
18 changes: 18 additions & 0 deletions examples/provider/provider-config-with-secret-google-identity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: ProviderConfig
metadata:
name: kubernetes-provider
spec:
credentials:
source: Secret
secretRef:
namespace: crossplane-system
name: cluster-config
key: kubeconfig
identity:
type: GoogleApplicationCredentials
source: Secret
secretRef:
name: gcp-credentials
namespace: crossplane-system
key: credentials.json
31 changes: 26 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
module github.com/crossplane-contrib/provider-kubernetes

go 1.19
go 1.20

require (
github.com/Azure/kubelogin v0.0.0-00010101000000-000000000000
github.com/crossplane/crossplane-runtime v1.14.3
github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79
github.com/google/go-cmp v0.6.0
github.com/pkg/errors v0.9.1
github.com/spf13/pflag v1.0.5
go.uber.org/zap v1.26.0
golang.org/x/oauth2 v0.14.0
gopkg.in/alecthomas/kingpin.v2 v2.2.6
Expand All @@ -22,6 +24,16 @@ require (
cloud.google.com/go/compute v1.20.1 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.29 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.23 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand All @@ -32,37 +44,41 @@ require (
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gobuffalo/flect v1.0.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.15.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.18.0 // indirect
Expand All @@ -75,13 +91,18 @@ require (
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/retry.v1 v1.0.3 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.28.3 // indirect
k8s.io/component-base v0.28.3 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

// This is a workaround until kubelogin project supports being consumed as a go module
// See https://github.com/Azure/kubelogin/pull/371
replace github.com/Azure/kubelogin => github.com/upbound/kubelogin v0.0.34-hotfix.1
Loading

0 comments on commit c8a78af

Please sign in to comment.