titansoft-pte-ltd / imagepullsecret-patcher

A simple Kubernetes client-go application that creates and patches imagePullSecrets to service accounts in all Kubernetes namespaces to allow cluster-wide authenticated access to private container registry.
https://medium.com/titansoft-engineering/kubernetes-cluster-wide-access-to-private-container-registry-with-imagepullsecret-patcher-b8b8fb79f7e5
MIT License
256 stars 91 forks source link

Example should be explicit about the usage of automountServiceAccountToken #8

Closed paul-pop closed 4 years ago

paul-pop commented 4 years ago

Thank you for this tool, it's a lifesaver for clusters with lots of namespaces πŸ‘

I have noticed during setup that for some versions of Terraform the automountServiceAccountToken is set to false by default so the pod fails to start:

πŸ‘‰  kubectl logs -f image-pull-secrets-55dc65c79f-7mlns
time="2020-07-20T14:59:54Z" level=info msg="Application started"
time="2020-07-20T14:59:54Z" level=panic msg="open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory"
panic: (*logrus.Entry) (0x12a2ac0,0xc000212d90)

goroutine 1 [running]:
github.com/sirupsen/logrus.Entry.log(0xc0000b8000, 0xc0001ebf80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /go/pkg/mod/github.com/sirupsen/logrus@v1.4.2/entry.go:239 +0x2db
github.com/sirupsen/logrus.(*Entry).Log(0xc000212cb0, 0xc000000000, 0xc0000c9f30, 0x1, 0x1)
    /go/pkg/mod/github.com/sirupsen/logrus@v1.4.2/entry.go:268 +0xeb
github.com/sirupsen/logrus.(*Logger).Log(0xc0000b8000, 0x0, 0xc0000c9f30, 0x1, 0x1)
    /go/pkg/mod/github.com/sirupsen/logrus@v1.4.2/logger.go:192 +0x7d
github.com/sirupsen/logrus.(*Logger).Panic(...)
    /go/pkg/mod/github.com/sirupsen/logrus@v1.4.2/logger.go:233
github.com/sirupsen/logrus.Panic(...)
    /go/pkg/mod/github.com/sirupsen/logrus@v1.4.2/exported.go:129
main.main()
    /app/main.go:56 +0x5c3

I will raise a PR to be explicit with the flag in the example and set it to true to avoid this edge-case.

billjh commented 4 years ago

@paul-pop thanks for your contribution. I've merged your change on the deploy-example