Skip to content

Commit

Permalink
Add cli parameter for kubeconfig and node name
Browse files Browse the repository at this point in the history
This is to add support for out-cluster development and testing.
Also removed Titlefile and deployment manifest as this can be tested
outside the cluster
  • Loading branch information
xcompass committed Feb 16, 2023
1 parent 6521cb0 commit ad40315
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 253 deletions.
15 changes: 12 additions & 3 deletions images/taint-manager/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# In Cluster Taint Manager

To add or remove taint of a node from a in-cluster pod.
To add or remove taint within a pod. The default mode is to run as a pod in a Kubernetes cluster. It will try to
authenticate to K8S API server with in-cluster config (the service account token mounted inside pod). It also uses
downward API to retrieve the node name where the pod is running on in order to change the taint.

## Compile

Expand All @@ -10,9 +12,16 @@ GOOS=linux GOARCH=amd64 go build -o taintmanager taintmanager.go

## Development and Debug

The dev/debug environment is setup by `tilt`. To start, run `tilt up`.
To test outside a cluster, commandline parameter `-kubeconfig` and `-node` can be specified. If `-kubeconfig` is not
specified, taintmanager will try to load the kubeconfig from default path `HOME/.kube/config`

## Test
Using default kubeconfig:

```
taintmanager -node f6.workers.ctlt.ubc.ca -remove hub.jupyter.org/imagepulling:NoExecute
```

## Test in Cluster

The `test` directory contains YAML files for deploy a pod with required permissions to run taintmanager.
Please change `namespace` field in `clusterrolebinding.yaml` before deploying to a cluster.
Expand Down
105 changes: 0 additions & 105 deletions images/taint-manager/Tiltfile

This file was deleted.

30 changes: 0 additions & 30 deletions images/taint-manager/deployment.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions images/taint-manager/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ require (
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // 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/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.2.0 // indirect
golang.org/x/oauth2 v0.2.0 // indirect
golang.org/x/sys v0.2.0 // indirect
Expand Down
3 changes: 3 additions & 0 deletions images/taint-manager/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28=
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
Expand Down Expand Up @@ -100,6 +102,7 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
Expand Down
Loading

0 comments on commit ad40315

Please sign in to comment.