Browse code

Add coredns rpms and docker image

Change-Id: Iaa966930ecdf743a2c345a9df260b182386f8516
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/5464
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Alexey Makhalov <amakhalov@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>

DheerajSShetty authored on 2018/08/07 07:57:45
Showing 4 changed files
... ...
@@ -438,6 +438,7 @@ k8s-docker-images: start-docker photon-docker-image
438 438
 	./build-k8s-base-image.sh $(PHOTON_RELEASE_VERSION) $(PHOTON_BUILD_NUMBER) $(PHOTON_STAGE)  && \
439 439
 	./build-k8s-docker-images.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \
440 440
 	./build-k8s-metrics-server-image.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE)  && \
441
+	./build-k8s-coredns-image.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE)  && \
441 442
 	./build-k8s-dns-docker-images.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \
442 443
 	./build-k8s-dashboard-docker-images.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \
443 444
 	./build-flannel-docker-image.sh $(PHOTON_DIST_TAG) $(PHOTON_RELEASE_VERSION) $(PHOTON_SPECS_DIR) $(PHOTON_STAGE) && \
444 445
new file mode 100644
... ...
@@ -0,0 +1,52 @@
0
+Summary:        CoreDNS
1
+Name:           coredns
2
+Version:        1.2.0
3
+Release:        1%{?dist}
4
+License:        Apache License 2.0
5
+URL:            https://github.com/coredns/coredns/archive/v%{version}.tar.gz
6
+Source0:        coredns-%{version}.tar.gz
7
+%define sha1    coredns-%{version}.tar.gz=68818ca8981750eba425be9b561c4724948d236d
8
+Group:          Development/Tools
9
+Vendor:         VMware, Inc.
10
+Distribution:   Photon
11
+BuildRequires:  go
12
+BuildRequires:  git
13
+%define debug_package %{nil}
14
+
15
+%description
16
+CoreDNS is a DNS server that chains plugins
17
+
18
+%prep -p exit
19
+%setup -qn coredns-%{version}
20
+
21
+%build
22
+export ARCH=amd64
23
+export VERSION=%{version}
24
+export PKG=github.com/%{name}/%{name}
25
+export GOARCH=${ARCH}
26
+export GOHOSTARCH=${ARCH}
27
+export GOOS=linux
28
+export GOHOSTOS=linux
29
+export GOROOT=/usr/lib/golang
30
+export GOPATH=/usr/share/gocode
31
+export GOBIN=/usr/share/gocode/bin
32
+export PATH=$PATH:$GOBIN
33
+mkdir -p ${GOPATH}/src/${PKG}
34
+cp -rf . ${GOPATH}/src/${PKG}
35
+pushd ${GOPATH}/src/${PKG}
36
+make
37
+
38
+%install
39
+install -m 755 -d %{buildroot}%{_bindir}
40
+install -pm 755 -t %{buildroot}%{_bindir} ${GOPATH}/src/github.com/%{name}/%{name}/coredns
41
+
42
+%clean
43
+rm -rf %{buildroot}/*
44
+
45
+%files
46
+%defattr(-,root,root)
47
+%{_bindir}/coredns
48
+
49
+%changelog
50
+*   Fri Aug 03 2018 Dheeraj Shetty <dheerajs@vmware.com> 1.2.0-1
51
+-   Initial version of coredns 1.2.0.
0 52
new file mode 100644
... ...
@@ -0,0 +1,8 @@
0
+FROM k8s-base-image:2.0
1
+
2
+MAINTAINER dheerajs@vmware.com
3
+
4
+COPY tmp/usr/bin/coredns /
5
+
6
+EXPOSE 53 53/udp
7
+ENTRYPOINT ["/coredns"]
0 8
new file mode 100755
... ...
@@ -0,0 +1,43 @@
0
+#!/bin/bash -e
1
+
2
+DIST_TAG=$1
3
+DIST_VER=$2
4
+SPEC_DIR=$3
5
+STAGE_DIR=$4
6
+ARCH=x86_64
7
+
8
+#
9
+# Docker images for coredns
10
+#
11
+K8S_COREDNS_VER=`cat ${SPEC_DIR}/coredns/coredns.spec | grep Version | cut -d: -f2 | tr -d ' '`
12
+K8S_COREDNS_VER_REL=${K8S_COREDNS_VER}-`cat ${SPEC_DIR}/coredns/coredns.spec | grep Release | cut -d: -f2 | tr -d ' ' | cut -d% -f1`
13
+K8S_COREDNS_RPM=coredns-${K8S_COREDNS_VER_REL}${DIST_TAG}.${ARCH}.rpm
14
+K8S_COREDNS_RPM_FILE=${STAGE_DIR}/RPMS/x86_64/${K8S_COREDNS_RPM}
15
+K8S_COREDNS_TAR=coredns-v${K8S_COREDNS_VER_REL}.tar
16
+
17
+if [ ! -f ${K8S_COREDNS_RPM_FILE} ]
18
+then
19
+    echo "Core DNS RPM ${K8S_COREDNS_RPM_FILE} not found. Exiting.."
20
+    exit 1
21
+fi
22
+
23
+IMG_NAME=vmware/photon-${DIST_VER}-coredns-amd64:v${K8S_COREDNS_VER}
24
+
25
+IMG_ID=`docker images -q ${IMG_NAME} 2> /dev/null`
26
+if [[ ! -z "${IMG_ID}" ]]; then
27
+    echo "Removing image ${IMG_NAME}"
28
+    docker rmi -f ${IMG_NAME}
29
+fi
30
+
31
+mkdir -p tmp
32
+cp ${K8S_COREDNS_RPM_FILE} tmp
33
+pushd ./tmp
34
+rpm2cpio ${K8S_COREDNS_RPM} | cpio -vid
35
+popd
36
+
37
+docker build --rm -t ${IMG_NAME} -f ./Dockerfile.coredns .
38
+docker save -o ${K8S_COREDNS_TAR} ${IMG_NAME}
39
+gzip ${K8S_COREDNS_TAR}
40
+mv -f ${K8S_COREDNS_TAR}.gz ${STAGE_DIR}/docker_images/
41
+
42
+rm -rf ./tmp