Closed PiotrProkop closed 7 years ago
@PiotrProkop It would be really great to get this fixed, as several projects I'm involved in would like to be able to use this functionality. Have you managed to make any progress on this?
@intlabs I tried to reproduce this problem and for us it work well. Are you sure the 'POD_NAME' env is set correctly?
I wrote some simple pod manifests to test your problem: Redis with init-container
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: redis
spec:
template:
metadata:
labels:
app: redis
annotations:
pod.beta.kubernetes.io/init-containers: '[
{
"name": "init",
"image": "quay.io/stackanetes/kubernetes-entrypoint:v0.1.0",
"imagePullPolicy": "IfNotPresent",
"env": [
{
"name": "NAMESPACE",
"value": "default"
},
{
"name": "DEPENDENCY_DAEMONSET",
"value": "ds2"
},
{
"name": "POD_NAME",
"value": "another-app-on-my-node"
},
{
"name": "COMMAND",
"value": "echo it_works"
}
]
}
]'
spec:
containers:
- name: redis
image: redis
imagePullPolicy: IfNotPresent
Simple daemon set for testing:
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: ds2
spec:
template:
metadata:
name: ds2
labels:
daemon: prom-node-exp-d2
spec:
containers:
- name: c
image: prom/prometheus
ports:
- containerPort: 9090
hostPort: 2020
name: serverport
When I start my deployment with redis everything works fine and redis is waiting for ds2 daemonset. After running my ds2 all dependencies are resolved and my redis is started.
If we remove
{
"name": "POD_NAME",
"value": "another-app-on-my-node"
},
part from redis manifest, and start redis again:
kubectl logs -f redis-693104266-xnpzw -c init
Entrypoint Error: 2017/01/13 11:26:15 daemonset.go:25: Cannot initialize daemonset: Env POD_NAME not set
goroutine 71 [running]:
panic(0x127b240, 0xc42040c000)
/usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/stackanetes/kubernetes-entrypoint/dependencies/daemonset.(*Daemonset).GetName(0x0, 0x147b318, 0xc42048a010)
<autogenerated>:2 +0xa4
github.com/stackanetes/kubernetes-entrypoint/entrypoint.Entrypoint.Resolve.func1(0xc42048a010, 0x1bd2f00, 0xc4200cff20, 0xc42000e0aa, 0x7, 0x1bc7b00, 0x0)
/home/pprokop/gopath/src/github.com/stackanetes/kubernetes-entrypoint/entrypoint/entrypoint.go:61 +0x8b
created by github.com/stackanetes/kubernetes-entrypoint/entrypoint.Entrypoint.Resolve
/home/pprokop/gopath/src/github.com/stackanetes/kubernetes-entrypoint/entrypoint/entrypoint.go:72 +0x102
I will prepare PR with README update and exception related with wrong POD_NAME.
@mzylowski Thanks for this! We were not using POD_NAME in our charts for either Kolla-K8s or OpenStack-Helm.
When running kubernetes-entrypoint in init-container daemoset dependency is returning nil *Daemonset pointer error.