Skip to content

Commit c8a78af

Browse files
authored
Merge pull request #170 from haarchri/feature/kubelogin-azure-ad-auth
feat(kubelogin): add kubelogin azure ad auth
2 parents 6bb6320 + 73d2e66 commit c8a78af

File tree

15 files changed

+542
-93
lines changed

15 files changed

+542
-93
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ on:
1010

1111
env:
1212
# Common versions
13-
GO_VERSION: '1.20.2'
14-
GOLANGCI_VERSION: 'v1.51.2'
13+
GO_VERSION: '1.20.12'
14+
GOLANGCI_VERSION: 'v1.55.2'
1515
DOCKER_BUILDX_VERSION: 'v0.8.2'
1616

1717
# Common users. We can't run a step 'if secrets.AWS_USR != ""' but we can run

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ GO_TEST_PARALLEL := $(shell echo $$(( $(NPROCS) / 2 )))
3030
GO_STATIC_PACKAGES = $(GO_PROJECT)/cmd/provider
3131
GO_SUBDIRS += cmd internal apis
3232
GO111MODULE = on
33-
GOLANGCILINT_VERSION = 1.51.2
33+
GOLANGCILINT_VERSION = 1.55.2
3434
-include build/makelib/golang.mk
3535

3636
# ====================================================================================
3737
# Setup Kubernetes tools
3838
KIND_VERSION = v0.18.0
39-
UP_VERSION = v0.17.0
40-
UPTEST_VERSION = v0.5.0
39+
UP_VERSION = v0.21.0
40+
UPTEST_VERSION = v0.9.0
4141
UP_CHANNEL = stable
4242
USE_HELM3 = true
4343
-include build/makelib/k8s_tools.mk
@@ -92,7 +92,7 @@ CROSSPLANE_NAMESPACE = crossplane-system
9292
UPTEST_EXAMPLE_LIST ?= "examples/object/object.yaml"
9393
uptest: $(UPTEST) $(KUBECTL) $(KUTTL)
9494
@$(INFO) running automated tests
95-
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) $(UPTEST) e2e "$(UPTEST_EXAMPLE_LIST)" --setup-script=cluster/test/setup.sh || $(FAIL)
95+
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=${CROSSPLANE_NAMESPACE} $(UPTEST) e2e "$(UPTEST_EXAMPLE_LIST)" --setup-script=cluster/test/setup.sh || $(FAIL)
9696
@$(OK) running automated tests
9797

9898
local-dev: controlplane.up

apis/v1alpha1/types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ type IdentityType string
4949
// Supported identity types.
5050
const (
5151
IdentityTypeGoogleApplicationCredentials = "GoogleApplicationCredentials"
52+
53+
IdentityTypeAzureServicePrincipalCredentials = "AzureServicePrincipalCredentials"
5254
)
5355

5456
// Identity used to authenticate.
5557
type Identity struct {
5658
// Type of identity.
57-
// +kubebuilder:validation:Enum=GoogleApplicationCredentials
59+
// +kubebuilder:validation:Enum=GoogleApplicationCredentials;AzureServicePrincipalCredentials
5860
Type IdentityType `json:"type"`
5961

6062
ProviderCredentials `json:",inline"`

cmd/provider/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package main
1818

1919
import (
20+
"io"
2021
"os"
2122
"path/filepath"
2223
"time"
@@ -52,6 +53,8 @@ func main() {
5253

5354
zl := zap.New(zap.UseDevMode(*debug), UseISO8601())
5455
log := logging.NewLogrLogger(zl.WithName("provider-kubernetes"))
56+
// explicitly provide a no-op logger by default, otherwise controller-runtime gives a warning
57+
ctrl.SetLogger(zap.New(zap.WriteTo(io.Discard)))
5558
if *debug {
5659
// The controller-runtime runs with a no-op logger by default. It is
5760
// *very* verbose even at info level, so we only provide it a real

examples/provider/config.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,3 @@ spec:
1818
namespace: crossplane-system
1919
name: cluster-config
2020
key: kubeconfig
21-
# identity:
22-
# type: GoogleApplicationCredentials
23-
# source: Secret
24-
# secretRef:
25-
# name: gcp-credentials
26-
# namespace: crossplane-system
27-
# key: credentials.json
28-
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: kubernetes.crossplane.io/v1alpha1
2+
kind: ProviderConfig
3+
metadata:
4+
name: kubernetes-provider
5+
spec:
6+
credentials:
7+
source: Secret
8+
secretRef:
9+
namespace: crossplane-system
10+
name: cluster-config
11+
key: kubeconfig
12+
identity:
13+
type: AzureServicePrincipalCredentials
14+
source: Secret
15+
secretRef:
16+
name: azure-credentials
17+
namespace: crossplane-system
18+
key: credentials.json
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: kubernetes.crossplane.io/v1alpha1
2+
kind: ProviderConfig
3+
metadata:
4+
name: kubernetes-provider
5+
spec:
6+
credentials:
7+
source: Secret
8+
secretRef:
9+
namespace: crossplane-system
10+
name: cluster-config
11+
key: kubeconfig
12+
identity:
13+
type: GoogleApplicationCredentials
14+
source: Secret
15+
secretRef:
16+
name: gcp-credentials
17+
namespace: crossplane-system
18+
key: credentials.json

go.mod

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
module github.com/crossplane-contrib/provider-kubernetes
22

3-
go 1.19
3+
go 1.20
44

55
require (
6+
github.com/Azure/kubelogin v0.0.0-00010101000000-000000000000
67
github.com/crossplane/crossplane-runtime v1.14.3
78
github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79
89
github.com/google/go-cmp v0.6.0
910
github.com/pkg/errors v0.9.1
11+
github.com/spf13/pflag v1.0.5
1012
go.uber.org/zap v1.26.0
1113
golang.org/x/oauth2 v0.14.0
1214
gopkg.in/alecthomas/kingpin.v2 v2.2.6
@@ -22,6 +24,16 @@ require (
2224
cloud.google.com/go/compute v1.20.1 // indirect
2325
cloud.google.com/go/compute/metadata v0.2.3 // indirect
2426
dario.cat/mergo v1.0.0 // indirect
27+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.8.0 // indirect
28+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 // indirect
29+
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
30+
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
31+
github.com/Azure/go-autorest/autorest v0.11.29 // indirect
32+
github.com/Azure/go-autorest/autorest/adal v0.9.23 // indirect
33+
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
34+
github.com/Azure/go-autorest/logger v0.2.1 // indirect
35+
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
36+
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0 // indirect
2537
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
2638
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
2739
github.com/beorn7/perks v1.0.1 // indirect
@@ -32,37 +44,41 @@ require (
3244
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
3345
github.com/fatih/color v1.15.0 // indirect
3446
github.com/fsnotify/fsnotify v1.6.0 // indirect
35-
github.com/go-logr/logr v1.2.4 // indirect
47+
github.com/go-logr/logr v1.3.0 // indirect
3648
github.com/go-logr/zapr v1.2.4 // indirect
3749
github.com/go-openapi/jsonpointer v0.19.6 // indirect
3850
github.com/go-openapi/jsonreference v0.20.2 // indirect
3951
github.com/go-openapi/swag v0.22.3 // indirect
4052
github.com/gobuffalo/flect v1.0.2 // indirect
4153
github.com/gogo/protobuf v1.3.2 // indirect
54+
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
55+
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
4256
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
4357
github.com/golang/protobuf v1.5.3 // indirect
4458
github.com/google/gnostic-models v0.6.8 // indirect
4559
github.com/google/gofuzz v1.2.0 // indirect
46-
github.com/google/uuid v1.3.1 // indirect
60+
github.com/google/uuid v1.4.0 // indirect
4761
github.com/imdario/mergo v0.3.16 // indirect
4862
github.com/inconshreveable/mousetrap v1.1.0 // indirect
4963
github.com/josharian/intern v1.0.0 // indirect
5064
github.com/json-iterator/go v1.1.12 // indirect
65+
github.com/kylelemons/godebug v1.1.0 // indirect
5166
github.com/mailru/easyjson v0.7.7 // indirect
5267
github.com/mattn/go-colorable v0.1.13 // indirect
5368
github.com/mattn/go-isatty v0.0.17 // indirect
5469
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
5570
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5671
github.com/modern-go/reflect2 v1.0.2 // indirect
5772
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
73+
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
5874
github.com/prometheus/client_golang v1.16.0 // indirect
5975
github.com/prometheus/client_model v0.4.0 // indirect
6076
github.com/prometheus/common v0.44.0 // indirect
6177
github.com/prometheus/procfs v0.10.1 // indirect
6278
github.com/spf13/afero v1.10.0 // indirect
6379
github.com/spf13/cobra v1.7.0 // indirect
64-
github.com/spf13/pflag v1.0.5 // indirect
6580
go.uber.org/multierr v1.11.0 // indirect
81+
golang.org/x/crypto v0.15.0 // indirect
6682
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
6783
golang.org/x/mod v0.13.0 // indirect
6884
golang.org/x/net v0.18.0 // indirect
@@ -75,13 +91,18 @@ require (
7591
google.golang.org/appengine v1.6.7 // indirect
7692
google.golang.org/protobuf v1.31.0 // indirect
7793
gopkg.in/inf.v0 v0.9.1 // indirect
94+
gopkg.in/retry.v1 v1.0.3 // indirect
7895
gopkg.in/yaml.v2 v2.4.0 // indirect
7996
gopkg.in/yaml.v3 v3.0.1 // indirect
8097
k8s.io/apiextensions-apiserver v0.28.3 // indirect
8198
k8s.io/component-base v0.28.3 // indirect
82-
k8s.io/klog/v2 v2.100.1 // indirect
99+
k8s.io/klog/v2 v2.110.1 // indirect
83100
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
84101
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
85102
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
86103
sigs.k8s.io/yaml v1.3.0 // indirect
87104
)
105+
106+
// This is a workaround until kubelogin project supports being consumed as a go module
107+
// See https://github.com/Azure/kubelogin/pull/371
108+
replace github.com/Azure/kubelogin => github.com/upbound/kubelogin v0.0.34-hotfix.1

0 commit comments

Comments
 (0)