Skip to content

Commit

Permalink
Merge pull request #19 from yunify/feature/add_buildscript
Browse files Browse the repository at this point in the history
Feature/add buildscript
  • Loading branch information
martinyunify authored Aug 29, 2017
2 parents 89dae0f + f53eb20 commit 628cb16
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 9 deletions.
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ services:
- docker
go:
- 1.8.x
before_install:
before_install:
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get update
- sudo apt-get -y install docker-ce

install:
- make release
script:
- echo "test skip"
before_deploy:
- make install

deploy:
provider: releases
api_key:
Expand Down
31 changes: 29 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
FROM alpine:edge AS build
RUN apk update
RUN apk upgrade
RUN apk add go gcc g++ make git linux-headers
WORKDIR /app
ENV GOPATH /app
ADD . /app/src/github.com/yunify/hostnic-cni
RUN cd /app/src/github.com/yunify/hostnic-cni && rm -rf bin/ && make go-build

FROM alpine:latest
MAINTAINER martinyunify <[email protected]>

ADD daemon /
COPY --from=build /app/src/github.com/yunify/hostnic-cni/bin/daemon /bin/daemon

EXPOSE 31080 31081

ENV LOGLEVEL info

ENV VXNETS vxnet-xxxxxxx

ENV POOLSIZE 3

ENV CLEANUPCACHEONEXIT false

RUN mkdir -p /opt/cni/bin/ && mkdir -p /etc/cni/net.d/

VOLUME /etc/qingcloud/

VOLUME /etc/cni/net.d/

COPY --from=build /app/src/github.com/yunify/hostnic-cni/bin/hostnic /opt/cni/bin/hostnic

ENTRYPOINT ["/bin/daemon"]

ENTRYPOINT ["/daemon"]
CMD ["start"]
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ bin/hostnic.tar.gz : bin/hostnic
bin/daemon : $(foreach dir,$(daemon_pkg),$(wildcard $(dir)/*.go))
go build -o bin/daemon $(GO_BUILD_FLAGS) $(GIT_REPOSITORY)/cmd/daemon/

bin/.docker-images-build-timestamp : bin/daemon
cp -u Dockerfile bin
docker build -q -t $(DOCKER_IMAGE_NAME):$(BUILD_LABEL) bin/ > bin/.docker-images-build-timestamp
bin/.docker-images-build-timestamp : $(foreach dir,$(daemon_pkg),$(wildcard $(dir)/*.go)) Dockerfile
docker build -q -t $(DOCKER_IMAGE_NAME):$(BUILD_LABEL) -t $(DOCKER_IMAGE_NAME):latest . > bin/.docker-images-build-timestamp

release : test bin/hostnic.tar.gz bin/.docker-images-build-timestamp

install : release
docker push $(DOCKER_IMAGE_NAME):$(BUILD_LABEL)
docker push $(DOCKER_IMAGE_NAME):latest

clean :
docker rmi `cat bin/.docker-images-build-timestamp`
Expand Down
2 changes: 1 addition & 1 deletion generate_version.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Define the project string to be used
PROJECT=hostnic-cni

Expand Down
119 changes: 119 additions & 0 deletions kube-hostnic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: hostnic
rules:
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- apiGroups:
- ""
resources:
- nodes
verbs:
- list
- watch
- apiGroups:
- ""
resources:
- nodes/status
verbs:
- patch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: hostnic
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: hostnic
subjects:
- kind: ServiceAccount
name: hostnic
namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: hostnic
namespace: kube-system
---
kind: ConfigMap
apiVersion: v1
metadata:
name: kube-hostnic-cni-cfg
namespace: kube-system
labels:
tier: node
app: hostnic
data:
10-hostnic.conf: |
{
"cniVersion": "0.3.1",
"name": "hostnic",
"type": "hostnic",
"bindaddr":"localhost:31080",
"ipam":{
"routes":[{"dst":"10.96.0.0/24","gw":"0.0.0.0"}]
},
"isGateway": true
}
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: kube-qingcloud-hostnic
namespace: kube-system
labels:
tier: node
app: kube-qingcloud-hostnic
spec:
template:
metadata:
labels:
tier: node
app: kube-qingcloud-hostnic
spec:
hostNetwork: true
nodeSelector:
beta.kubernetes.io/arch: amd64
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
serviceAccountName: hostnic
containers:
- name: kube-qingcloud-hostnic
image: dockerhub.qingcloud.com/qingcloud/hostnic-cni:hostnic-cni-v0.8-1-g89dae0f
command: [ "start" ]
securityContext:
privileged: true
env:
- name: LOGLEVEL
value: "info"

- name: VXNETS
value: "vxnet-2xj9lrp,vxnet-h00g66q"

- name: POOLSIZE
value: "3"

volumeMounts:
- name: hostnic-cfg
mountPath: /etc/cni/

- name: qingcloud-cfg
mountPath: /etc/qingcloud/

volumes:
- name: hostnic-cfg
configMap:
name: kube-hostnic-cni-cfg

- name: qingcloud-cfg
hostPath:
path: /etc/qingcloud/

0 comments on commit 628cb16

Please sign in to comment.