I came across with this problem. This problem can be replayed by following steps.
The way to replay this issue. Before start I run the docker in this mode
/usr/bin/docker -d -H fd:// --iptables=false
Firstly Run the etcd , I run the etcd on the docker container.
docker run --net=host -d gcr.io/google_containers/etcd:2.0.12 /usr/local/bin/etcd --addr=yourHostIp:4001 --bind-addr=0.0.0.0:4001 --data-dir=/var/etcd/data
Secondly
docker pull gcr.io/google_containers/hyperkube:v1.0.1
Run the container through docker run: After install vim in the container I change the file /etc/kubernetes/manifests/master.json as follows:
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"k8s-master"},
"spec":{
"hostNetwork": true,
"containers":[
{
"name": "controller-manager",
"image": "gcr.io/google_containers/hyperkube:self-1.0.1",
"command": [
"/hyperkube",
"controller-manager",
"--master=yourHostIp:8080",
"--v=2"
]
},
{
"name": "apiserver",
"image": "gcr.io/google_containers/hyperkube:self-1.0.1",
"command": [
"/hyperkube",
"apiserver",
"--portal-net=10.0.0.1/24",
"--address=yourHostIp",
"--etcd_servers=http://yourHostIp:4001",
"--cluster_name=kubernetes",
"--v=2"
]
},
{
"name": "scheduler",
"image": "gcr.io/google_containers/hyperkube:self-1.0.1",
"command": [
"/hyperkube",
"scheduler",
"--master=yourHostIp:8080",
"--v=2"
]
}
]
}
}
Then I save this changed container as gcr.io/google_containers/hyperkube:self-1.0.1
Thirdly: Then I run the changed image through follow command
docker run \
--volume=/:/rootfs:ro \
--volume=/sys:/sys:ro \
--volume=/dev:/dev \
--volume=/var/lib/docker/:/var/lib/docker:ro \
--volume=/var/lib/kubelet/:/var/lib/kubelet:rw \
--volume=/var/run:/var/run:rw \
--net=host --pid=host --privileged=true -d \
gcr.io/google_containers/hyperkube:self-1.0.1 \
/hyperkube kubelet --containerized --hostname-override="10.4.28.51" --address="0.0.0.0" --api-servers=http://yourHostIp:8080 --allow-privileged=true --config=/etc/kubernetes/manifests
Finnaly
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"redis-master"},
"spec":{
"hostNetwork": true,
"containers":[
{
"name": "redis-test",
"image": "redis:2.8"
}
]
}
}
create pod through above file
kubectrl create -f example.json
And when you run
kubectl get pod
You should find this: And I'm wonder why the pod of k8s-master-yourHostIp running normally.
NAME READY STATUS RESTARTS AGE
k8s-master-yourHostIp 3/3 Running 0 1h
redis-master 0/1 Image: redis:2.8 is ready, container is creating 0 6s
And when you try
kubectl -s $(hn):8080 describe pod redis-master
You should find
root@XXX:~/kubernetes/examples/redis# kubectl -s $(hn):8080 describe pod redis-master
Name: redis-master
Namespace: default
Image(s): redis:2.8
Node: yourHostIp/yourHostIp
Start Time: Tue, 08 Dec 2015 11:59:06 +0800
Labels: <none>
Status: Pending
Reason:
Message:
IP: yourHostIp
Replication Controllers: <none>
Containers:
redis-test:
Container ID:
Image: redis:2.8
Image ID:
State: Waiting
Reason: Image: redis:2.8 is ready, container is creating
Ready: False
Restart Count: 0
Environment Variables:
Conditions:
Type Status
Ready False
No volumes.
Events:
FirstSeen LastSeen Count From SubobjectPath Reason Message
───────── ──────── ───── ──── ───────────── ────── ───────
5m 5m 1 {scheduler } scheduled Successfully assigned redis-master to yourHostIp
5m 8s 34 {kubelet yourHostIp} failedSync Error syncing pod, skipping: pod with UID "06b96a71-9d60-11e5-ae3c-008cfaeeacb2" specified host networking, but is disallowed
So is there anything I misunderstood?
Add the following kubelet flag: --host-network-sources="*"
This is the default in Kubernetes 1.1 and later. I recommend updating to 1.1.7, if you can.