Skip to content

Commit

Permalink
Tweak Dockerfile to install bins on k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
caseydavenport committed Aug 3, 2016
1 parent ed9f217 commit 680a732
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
FROM debian:jessie
MAINTAINER projectcalico

# Add binaries to image.
RUN mkdir -p /opt/cni/bin
ADD ./dist/calico /opt/cni/bin
ADD ./dist/calico-ipam /opt/cni/bin

# Add CNI install script.
ADD ./scripts/install-cni.sh /install-cni.sh

# Set volume, environment, and working directory.
VOLUME /opt/cni
ENV PATH=$PATH:/opt/cni/bin
WORKDIR /opt/cni/bin
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ dist/calico-ipam: $(SRCFILES)

# Makes a docker image
dist/docker:
docker build -t calico/cni .
docker tag calico/cni calico/cni:$(CALICO_VERSION)
docker build -t caseydavenport/cni:latest .
#docker build -t calico/cni .
#docker tag calico/cni calico/cni:$(CALICO_VERSION)

# Updates the version information in version.py
update-version:
Expand Down
41 changes: 41 additions & 0 deletions scripts/install-cni.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# Script to install Calico CNI on a Kubernetes host.
# Expects the CNI binary path to be mounted in to the
# `calico/cni` container at /host/opt/cni/bin.
# Expects the CNI network config path to be mounted in
# to the `calico/cni` container at /host/etc/cni/net.d.

# Place the binaries.
rm -f /host/opt/cni/bin/calico /host/opt/cni/bin/calico-ipam
cp /opt/cni/bin/calico /host/opt/cni/bin/calico
cp /opt/cni/bin/calico-ipam /host/opt/cni/bin/calico-ipam
echo "Wrote Calico CNI binaries to /host/opt/cni/bin/"
echo "Version: $(/host/opt/cni/bin/calico -v)"

# Make the network configuration file.
cat >/host/etc/cni/net.d/10-calico.conf <<EOF
{
"name": "calico-k8s-network",
"type": "calico",
"etcd_endpoints": "http://172.18.18.101:2379",
"log_level": "debug",
"ipam": {
"type": "calico-ipam"
},
"policy": {
"type": "k8s",
"k8s_api_root": "https://172.18.18.101:443/api/v1/",
"k8s_client_certificate": "/etc/kubernetes/ssl/worker.pem",
"k8s_client_key": "/etc/kubernetes/ssl/worker-key.pem"
}
}
EOF

echo "Wrote CNI config to disk: $(cat /host/etc/cni/net.d/10-calico.conf)"

# And finally, sleep forever.
echo "Done configuring CNI, sleeping"
while true; do
sleep 1;
done

0 comments on commit 680a732

Please sign in to comment.