swipely / iam-docker

Use different IAM roles for each Docker container on an EC2 instance
MIT License
211 stars 22 forks source link

Working with a K8s cluster #14

Closed kenwan12 closed 7 years ago

kenwan12 commented 8 years ago

When I tried to deploy it into a K8s cluster, I got logs liek the following

2016-10-21T12:25:16Z [app] Running the app 2016-10-21T12:25:16Z [app] Starting worker=event-handler 2016-10-21T12:25:16Z [docker] Starting event handler event-handler=4 2016-10-21T12:25:16Z [app] Starting worker=sync-containers 2016-10-21T12:25:16Z [app] Syncing containers worker=sync-containers 2016-10-21T12:25:16Z [docker] Syncing the running containers 2016-10-21T12:25:16Z [app] Starting worker=refresh-credentials 2016-10-21T12:25:16Z [app] Starting worker=http 2016-10-21T12:25:16Z [docker] Starting event handler event-handler=1 2016-10-21T12:25:16Z [docker] Starting event handler event-handler=2 2016-10-21T12:25:16Z [docker] Starting event handler event-handler=3 2016-10-21T12:25:17Z [docker] Docker events channel closed event-handler=3 2016-10-21T12:25:17Z [docker] Docker events channel closed event-handler=4 2016-10-21T12:25:17Z [docker] Docker events channel closed event-handler=1 2016-10-21T12:25:17Z [docker] Docker events channel closed event-handler=2 2016-10-21T12:25:17Z [app] Exited worker=event-handler error="Docker events connection closed" 2016-10-21T12:25:17Z [docker] Starting event handler event-handler=4 2016-10-21T12:25:17Z [docker] Starting event handler event-handler=1 2016-10-21T12:25:17Z [docker] Starting event handler event-handler=2 2016-10-21T12:25:17Z [docker] Starting event handler event-handler=3 2016-10-21T12:25:17Z [docker] Docker events channel closed event-handler=3 2016-10-21T12:25:17Z [docker] Docker events channel closed event-handler=4 2016-10-21T12:25:17Z [docker] Docker events channel closed event-handler=1 2016-10-21T12:25:17Z [docker] Docker events channel closed event-handler=2 2016-10-21T12:25:17Z [app] Exited worker=event-handler error="Docker events connection closed"

Looks like not being able to get proper docker events.

Have anyone had similar experience please ?

Thanks

Ken

nahiluhmot commented 8 years ago

Thanks for opening the issue, Ken.

A few questions:

kenwan12 commented 8 years ago

Oh, I forgot about the socket ! Will work on getting the right deployment for it onto k8s then.

Thx

Ken


Docker version given below which is for information only - core@ip-xxx ~ $ docker version Client: Version: 1.10.3 API version: 1.22 Go version: go1.5.4 Git commit: 1f8f545 Built:
OS/Arch: linux/amd64

Server: Version: 1.10.3 API version: 1.22 Go version: go1.5.4 Git commit: 1f8f545 Built:
OS/Arch: linux/amd64

kenwan12 commented 8 years ago

Got the iamloader running on a K8s cluster and if I started manually on a worker node a fstab/aws-cli container with IAM_PROFILE=the_wanted_role, it gets the access OK.

But if I start it via kubectl, I got these messages from the iamloader's log


2016-10-21T15:57:26Z [iam] Done refreshing all IAM credentials 2016-10-21T15:57:36Z [docker] Adding container event-handler=2 id=c216957c95bc6e1369808803a3331b7d2d49a4ae979391131a2c30b6a618be2f event=start 2016-10-21T15:57:36Z [docker] Adding container event=start id=551cbda3564b464ddda7728a0baa4724868ad00a30b69052b868bee66b690059 event-handler=3 2016-10-21T15:57:37Z [docker] Unable to add container event=start error="Unable to find label named 'com.swipely.iam-docker.iam-profile' or environment variable 'IAM_ROLE' for container: 551cbda3564b464ddda7728a0baa4724868ad00a30b69052b868bee66b690059" id=551cbda3564b464ddda7728a0baa4724868ad00a30b69052b868bee66b690059 event-handler=3 2016-10-21T15:57:37Z [docker] Unable to add container event-handler=2 id=c216957c95bc6e1369808803a3331b7d2d49a4ae979391131a2c30b6a618be2f event=start error="Unable to find label named 'com.swipely.iam-docker.iam-profile' or environment variable 'IAM_ROLE' for container: c216957c95bc6e1369808803a3331b7d2d49a4ae979391131a2c30b6a618be2f" 2016-10-21T15:57:38Z [docker] Adding container event-handler=3 id=3de7fde2e71e650de04072e34b20ab370553a9b371431d7b92de24ab961aa861 event=start 2016-10-21T15:57:39Z [docker] Unable to add container event-handler=3 id=3de7fde2e71e650de04072e34b20ab370553a9b371431d7b92de24ab961aa861 event=start error="Unable to find IP address for container: 3de7fde2e71e650de04072e34b20ab370553a9b371431d7b92de24ab961aa861" 2016-10-21T15:57:39Z [docker] Adding container event-handler=4 id=7c8910280de7e07c940eb973a6f5ae60ac6c3e86b7da030f392c5a26bd064b6f event=start 2016-10-21T15:57:40Z [docker] Unable to add container id=7c8910280de7e07c940eb973a6f5ae60ac6c3e86b7da030f392c5a26bd064b6f event=start event-handler=4 error="Unable to find IP address for container: 7c8910280de7e07c940eb973a6f5ae60ac6c3e86b7da030f392c5a26bd064b6f"


Any idea please ? Thx

Ken

nahiluhmot commented 7 years ago

You have to use the IAM_ROLE environment variable, not IAM_PROFILE.

Also, be sure that the instance on which kubernetes is running has permissions to assume $the_wanted_role.

nahiluhmot commented 7 years ago

@kenwan12 I'm going to close this issue. Feel free to re-open if you're still having problems.