Skip to content

Commit 6967a33

Browse files
authored
Merge pull request #32 from iastewar/watch-namespaces
Added goroutine to watch namespaces and add secrets
2 parents ac6c872 + 81aabd8 commit 6967a33

File tree

4 files changed

+638
-93
lines changed

4 files changed

+638
-93
lines changed

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
# gcp-auth-webhook
2-
A mutating webhook that will patch any pods in your kubernetes cluster with GCP credentials (whose location is currently hardcoded to /var/lib/minikube/google_application_credentials.json)
32

4-
Use the image gcr.io/k8s-minikube/gcp-auth-webhook as the image for a Deployment in your Kubernetes manifest and add that to a MutatingWebhookConfiguration.
3+
A server that includes:
4+
* A mutating webhook that will patch any newly created pods in your Kubernetes cluster with GCP credentials (whose location is currently hardcoded to /var/lib/minikube/google_application_credentials.json).
5+
* A mutating webhook that will patch any newly created service accounts in your Kubernetes cluster with an image pull secret.
6+
* A thread that monitors namespaces to make sure all namespaces include a image pull secret to be able to pull from GCR and AR.
7+
8+
## Deployment
9+
Use the image `gcr.io/k8s-minikube/gcp-auth-webhook` as the image for a Deployment in your Kubernetes manifest and add that to a MutatingWebhookConfiguration. See [minikube](https://github.com/kubernetes/minikube/blob/master/deploy/addons/gcp-auth/gcp-auth-webhook.yaml.tmpl) for details.
10+
11+
## Running Locally
12+
The easiest way to run the server locally is:
13+
* Remove `FROM scratch` in the Dockerfile and replace it with the following to ensure https requests work properly locally:
14+
```
15+
FROM alpine
16+
RUN apk --no-cache add ca-certificates
17+
```
18+
* Modify [minikube's](https://github.com/kubernetes/minikube/blob/master/deploy/addons/gcp-auth/gcp-auth-webhook.yaml.tmpl) gcp-auth Deployment image to be `local/gcp-auth-webhook:$(VERSION)` (replace `$(VERSION)` with your version)
19+
* Build and run minikube
20+
* Run `eval $(path_to_minikube/minikube docker-env)` and then `make local-image` to make the image available from within minikube
21+
* Run `path_to_minikube/minikube addons enable gcp-auth` to enable the addon, which creates a pod in the `gcp-auth` namespace with the gcp-auth-webhook server

go.mod

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,48 @@ module github.com/GoogleContainerTools/gcp-auth-webhook
33
go 1.18
44

55
require (
6+
github.com/GoogleCloudPlatform/docker-credential-gcr v2.0.5+incompatible
67
github.com/blang/semver/v4 v4.0.0
7-
k8s.io/api v0.24.1
8-
k8s.io/apimachinery v0.24.1
8+
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
9+
k8s.io/api v0.25.4
10+
k8s.io/apimachinery v0.25.4
11+
k8s.io/client-go v0.25.4
912
)
1013

1114
require (
12-
github.com/go-logr/logr v1.2.0 // indirect
15+
cloud.google.com/go v0.97.0 // indirect
16+
github.com/PuerkitoBio/purell v1.1.1 // indirect
17+
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
18+
github.com/davecgh/go-spew v1.1.1 // indirect
19+
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
20+
github.com/go-logr/logr v1.2.3 // indirect
21+
github.com/go-openapi/jsonpointer v0.19.5 // indirect
22+
github.com/go-openapi/jsonreference v0.19.5 // indirect
23+
github.com/go-openapi/swag v0.19.14 // indirect
1324
github.com/gogo/protobuf v1.3.2 // indirect
25+
github.com/golang/protobuf v1.5.2 // indirect
26+
github.com/google/gnostic v0.5.7-v3refs // indirect
1427
github.com/google/gofuzz v1.1.0 // indirect
28+
github.com/josharian/intern v1.0.0 // indirect
1529
github.com/json-iterator/go v1.1.12 // indirect
30+
github.com/mailru/easyjson v0.7.6 // indirect
1631
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
1732
github.com/modern-go/reflect2 v1.0.2 // indirect
18-
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
33+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
34+
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
35+
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
36+
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
1937
golang.org/x/text v0.3.7 // indirect
38+
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
39+
google.golang.org/appengine v1.6.7 // indirect
40+
google.golang.org/protobuf v1.28.0 // indirect
2041
gopkg.in/inf.v0 v0.9.1 // indirect
2142
gopkg.in/yaml.v2 v2.4.0 // indirect
22-
k8s.io/klog/v2 v2.60.1 // indirect
23-
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
24-
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
25-
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
43+
gopkg.in/yaml.v3 v3.0.1 // indirect
44+
k8s.io/klog/v2 v2.70.1 // indirect
45+
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
46+
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect
47+
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
48+
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
2649
sigs.k8s.io/yaml v1.2.0 // indirect
2750
)

0 commit comments

Comments
 (0)