Skip to content

Commit 8167e06

Browse files
authored
Merge pull request #53 from senthilrch/senthilrch
PR for v0.6.0
2 parents 22f0a75 + 031efbb commit 8167e06

39 files changed

+996
-102
lines changed

.travis.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
language: go
22
go:
3-
- 1.13.5
3+
- 1.13.8
44
install:
55
- go get golang.org/x/tools/cmd/cover
66
- go get github.com/mattn/goveralls
77
- go get -u golang.org/x/lint/golint
88
script:
9-
- hack/verify-codegen.sh
10-
- hack/verify-boilerplate.sh
11-
- hack/verify-gofmt.sh
12-
- hack/verify-golint.sh
13-
- hack/verify-govet.sh
14-
- make fledged-image
15-
- make client-image
16-
- make test
17-
- $(go env GOPATH | awk 'BEGIN{FS=":"} {print $1}')/bin/goveralls -coverprofile=coverage.out -service=travis-ci
9+
- hack/verify-codegen.sh
10+
- hack/verify-boilerplate.sh
11+
- hack/verify-gofmt.sh
12+
- hack/verify-golint.sh
13+
- hack/verify-govet.sh
14+
- make fledged-dev
15+
- make GIT_BRANCH=${TRAVIS_BRANCH} build-images
16+
- make test
17+
- $(go env GOPATH | awk 'BEGIN{FS=":"} {print $1}')/bin/goveralls -coverprofile=coverage.out -service=travis-ci

Makefile

Lines changed: 73 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
.PHONY: clean clean-fledged clean-client fledged-image client-image push-images test deploy update remove
15+
.PHONY: clean clean-fledged clean-client clean-operator fledged-dev fledged-image client-image operator-image build-images push-images test deploy update remove
1616
# Default tag and architecture. Can be overridden
1717
TAG?=$(shell git describe --tags --dirty)
1818
ARCH?=amd64
@@ -23,30 +23,48 @@ else
2323
CGO_ENABLED=0
2424
endif
2525

26-
# Go version to use for builds
27-
GO_VERSION=1.11.1
26+
GOARM=7
2827

29-
# K8s version used for Makefile helpers
30-
K8S_VERSION=v1.12.0
28+
ifndef FLEDGED_IMAGE_REPO
29+
FLEDGED_IMAGE_REPO=docker.io/senthilrch/fledged
30+
endif
3131

32-
GOARM=7
32+
ifndef FLEDGED_DOCKER_CLIENT_IMAGE_REPO
33+
FLEDGED_DOCKER_CLIENT_IMAGE_REPO=docker.io/senthilrch/fledged-docker-client
34+
endif
3335

34-
ifndef FLEDGED_IMAGE_NAME
35-
FLEDGED_IMAGE_NAME=senthilrch/fledged:latest
36+
ifndef OPERATOR_IMAGE_REPO
37+
OPERATOR_IMAGE_REPO=docker.io/senthilrch/kubefledged-operator
3638
endif
3739

38-
ifndef FLEDGED_DOCKER_CLIENT_IMAGE_NAME
39-
FLEDGED_DOCKER_CLIENT_IMAGE_NAME=senthilrch/fledged-docker-client:latest
40+
ifndef RELEASE_VERSION
41+
RELEASE_VERSION=v0.6.0
4042
endif
4143

4244
ifndef DOCKER_VERSION
43-
DOCKER_VERSION=19.03.5
45+
DOCKER_VERSION=19.03.7
4446
endif
4547

4648
ifndef CRICTL_VERSION
4749
CRICTL_VERSION=v1.17.0
4850
endif
4951

52+
ifndef GOLANG_VERSION
53+
GOLANG_VERSION=1.13.8
54+
endif
55+
56+
ifndef ALPINE_VERSION
57+
ALPINE_VERSION=3.11
58+
endif
59+
60+
ifndef OPERATORSDK_VERSION
61+
OPERATORSDK_VERSION=v0.15.2
62+
endif
63+
64+
ifndef GIT_BRANCH
65+
GIT_BRANCH=master
66+
endif
67+
5068
HTTP_PROXY_CONFIG=
5169
ifdef HTTP_PROXY
5270
HTTP_PROXY_CONFIG=--build-arg http_proxy=${HTTP_PROXY}
@@ -59,59 +77,71 @@ endif
5977

6078

6179
### BUILDING
62-
clean: clean-fledged clean-client
80+
clean: clean-fledged clean-client clean-operator
6381

6482
clean-fledged:
6583
-rm -f build/fledged
66-
-rm -f build/fledged.tar.gz
67-
-docker image rm $(FLEDGED_IMAGE_NAME)
84+
-docker image rm $(FLEDGED_IMAGE_REPO):$(RELEASE_VERSION)
6885
-docker image rm `docker image ls -f dangling=true -q`
6986

7087
clean-client:
71-
-rm -f build/fledged-docker-client.tar.gz
72-
-docker image rm $(FLEDGED_DOCKER_CLIENT_IMAGE_NAME)
88+
-docker image rm $(FLEDGED_DOCKER_CLIENT_IMAGE_REPO):$(RELEASE_VERSION)
89+
-docker image rm `docker image ls -f dangling=true -q`
90+
91+
clean-operator:
92+
-docker image rm $(OPERATOR_IMAGE_REPO):$(RELEASE_VERSION)
7393
-docker image rm `docker image ls -f dangling=true -q`
7494

75-
fledged:
76-
CGO_ENABLED=0 go build -o build/fledged \
77-
-ldflags '-s -w -extldflags "-static"' cmd/fledged.go
95+
fledged-dev: clean-fledged
96+
CGO_ENABLED=0 go build -o build/fledged -ldflags '-s -w -extldflags "-static"' cmd/fledged.go && \
97+
cd build && docker build -t $(FLEDGED_IMAGE_REPO):$(RELEASE_VERSION) -f Dockerfile.fledged_dev \
98+
--build-arg ALPINE_VERSION=${ALPINE_VERSION} .
7899

79-
fledged-image: clean-fledged fledged
80-
cd build && docker build -t $(FLEDGED_IMAGE_NAME) . && \
81-
docker save -o fledged.tar $(FLEDGED_IMAGE_NAME) && \
82-
gzip fledged.tar
100+
fledged-image: clean-fledged
101+
cd build && docker build -t $(FLEDGED_IMAGE_REPO):$(RELEASE_VERSION) -f Dockerfile.fledged \
102+
${HTTP_PROXY_CONFIG} ${HTTPS_PROXY_CONFIG} --build-arg GIT_BRANCH=${GIT_BRANCH} \
103+
--build-arg GOLANG_VERSION=${GOLANG_VERSION} --build-arg ALPINE_VERSION=${ALPINE_VERSION} .
83104

84105
client-image: clean-client
85-
cd build && docker build -t $(FLEDGED_DOCKER_CLIENT_IMAGE_NAME) \
106+
cd build && docker build -t $(FLEDGED_DOCKER_CLIENT_IMAGE_REPO):$(RELEASE_VERSION) \
86107
-f Dockerfile.docker_client ${HTTP_PROXY_CONFIG} ${HTTPS_PROXY_CONFIG} \
87-
--build-arg DOCKER_VERSION=${DOCKER_VERSION} --build-arg CRICTL_VERSION=${CRICTL_VERSION} . && \
88-
docker save -o fledged-docker-client.tar $(FLEDGED_DOCKER_CLIENT_IMAGE_NAME) && \
89-
gzip fledged-docker-client.tar
108+
--build-arg DOCKER_VERSION=${DOCKER_VERSION} --build-arg CRICTL_VERSION=${CRICTL_VERSION} \
109+
--build-arg ALPINE_VERSION=${ALPINE_VERSION} .
110+
111+
operator-image: clean-operator
112+
cd deploy/kubefledged-operator && \
113+
docker build -t $(OPERATOR_IMAGE_REPO):$(RELEASE_VERSION) -f ./build/Dockerfile \
114+
--build-arg OPERATORSDK_VERSION=${OPERATORSDK_VERSION} .
115+
116+
build-images: fledged-image client-image operator-image
117+
118+
push-images:
119+
-docker push $(FLEDGED_IMAGE_REPO):$(RELEASE_VERSION)
120+
-docker push $(FLEDGED_DOCKER_CLIENT_IMAGE_REPO):$(RELEASE_VERSION)
121+
-docker push $(OPERATOR_IMAGE_REPO):$(RELEASE_VERSION)
90122

91-
push-image:
92-
-docker push $(FLEDGED_IMAGE_NAME)
93-
-docker push $(FLEDGED_DOCKER_CLIENT_IMAGE_NAME)
123+
release: build-images push-images
94124

95125
test:
96126
-rm -f coverage.out
97127
bash hack/run-unit-tests.sh
98128

99129
deploy:
100-
kubectl apply -f deploy/fledged-crd.yaml && sleep 2 && \
101-
kubectl apply -f deploy/fledged-namespace.yaml && sleep 2 && \
102-
kubectl apply -f deploy/fledged-serviceaccount.yaml && \
103-
kubectl apply -f deploy/fledged-clusterrole.yaml && \
104-
kubectl apply -f deploy/fledged-clusterrolebinding.yaml && \
105-
kubectl apply -f deploy/fledged-deployment.yaml
130+
kubectl apply -f deploy/kubefledged-crd.yaml && sleep 2 && \
131+
kubectl apply -f deploy/kubefledged-namespace.yaml && sleep 2 && \
132+
kubectl apply -f deploy/kubefledged-serviceaccount.yaml && \
133+
kubectl apply -f deploy/kubefledged-clusterrole.yaml && \
134+
kubectl apply -f deploy/kubefledged-clusterrolebinding.yaml && \
135+
kubectl apply -f deploy/kubefledged-deployment.yaml
106136

107137
update:
108-
kubectl scale deployment fledged --replicas=0 -n kube-fledged && sleep 5 && \
109-
kubectl scale deployment fledged --replicas=1 -n kube-fledged && sleep 5 && \
110-
kubectl get pods -l app=fledged -n kube-fledged
138+
kubectl scale deployment kubefledged --replicas=0 -n kube-fledged && sleep 5 && \
139+
kubectl scale deployment kubefledged --replicas=1 -n kube-fledged && sleep 5 && \
140+
kubectl get pods -l app=kubefledged -n kube-fledged
111141

112142
remove:
113-
kubectl delete -f deploy/fledged-namespace.yaml && \
114-
kubectl delete -f deploy/fledged-clusterrolebinding.yaml && \
115-
kubectl delete -f deploy/fledged-clusterrole.yaml && \
116-
kubectl delete -f deploy/fledged-crd.yaml
143+
kubectl delete -f deploy/kubefledged-namespace.yaml && \
144+
kubectl delete -f deploy/kubefledged-clusterrolebinding.yaml && \
145+
kubectl delete -f deploy/kubefledged-clusterrole.yaml && \
146+
kubectl delete -f deploy/kubefledged-crd.yaml
117147

README.md

Lines changed: 88 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# kube-fledged
1+
<img src="logo.png">
2+
3+
#
24

35
[![Build Status](https://travis-ci.org/senthilrch/kube-fledged.svg?branch=master)](https://travis-ci.org/senthilrch/kube-fledged)
46
[![Coverage Status](https://coveralls.io/repos/github/senthilrch/kube-fledged/badge.svg?branch=master)](https://coveralls.io/github/senthilrch/kube-fledged?branch=master)
@@ -11,6 +13,34 @@ of images and onto which worker nodes those images should be cached (i.e. pre-pu
1113

1214
_kube-fledged_ provides CRUD APIs to manage the lifecycle of the image cache, and supports several configurable parameters to customize the functioning as per one's needs.
1315

16+
## Table of contents
17+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
18+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
19+
20+
21+
- [Use cases](#use-cases)
22+
- [Prerequisites](#prerequisites)
23+
- [Quick Install using YAML manifests](#quick-install-using-yaml-manifests)
24+
- [Quick Install using Helm operator](#quick-install-using-helm-operator)
25+
- [Build and Deploy](#build-and-deploy)
26+
- [Build](#build)
27+
- [Deploy](#deploy)
28+
- [How to use](#how-to-use)
29+
- [Create image cache](#create-image-cache)
30+
- [View the status of image cache](#view-the-status-of-image-cache)
31+
- [Add/remove images in image cache](#addremove-images-in-image-cache)
32+
- [Refresh image cache](#refresh-image-cache)
33+
- [Delete image cache](#delete-image-cache)
34+
- [Remove kube-fledged](#remove-kube-fledged)
35+
- [How it works](#how-it-works)
36+
- [Configuration Flags](#configuration-flags)
37+
- [Supported Platforms](#supported-platforms)
38+
- [Built With](#built-with)
39+
- [Contributing](#contributing)
40+
- [License](#license)
41+
42+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
43+
1444
## Use cases
1545

1646
- Applications that require rapid start-up. For e.g. an application performing real-time data processing needs to scale rapidly due to a burst in data volume.
@@ -25,9 +55,9 @@ _kube-fledged_ provides CRUD APIs to manage the lifecycle of the image cache, an
2555
- Supported container runtimes: docker, containerd, cri-o
2656
- git, make, go, docker and kubectl installed on a local linux machine. kubectl configured properly to access the cluster.
2757

28-
## Quick Install
58+
## Quick Install using YAML manifests
2959

30-
These instructions install _kube-fledged_ using pre-built images of the latest stable release in [Docker Hub.](https://hub.docker.com/u/senthilrch)
60+
These instructions install _kube-fledged_ to a separate namespace called "kube-fledged", using YAML manifests and pre-built images in [Docker Hub.](https://hub.docker.com/u/senthilrch)
3161

3262
- Clone the source code repository
3363

@@ -46,14 +76,57 @@ These instructions install _kube-fledged_ using pre-built images of the latest s
4676
- Verify if _kube-fledged_ deployed successfully
4777

4878
```
49-
$ kubectl get pods -n kube-fledged -l app=fledged
79+
$ kubectl get pods -n kube-fledged -l app=kubefledged
80+
$ kubectl logs -f <pod_name_obtained_from_above_command> -n kube-fledged
81+
$ kubectl get imagecaches -n kube-fledged (Output should be: 'No resources found')
82+
```
83+
84+
## Quick Install using Helm operator
85+
86+
These instructions install _kube-fledged_ to a separate namespace called "kube-fledged", using Helm operator and pre-built images in [Docker Hub.](https://hub.docker.com/u/senthilrch)
87+
88+
- Clone the source code repository
89+
90+
```
91+
$ mkdir -p $HOME/src/github.com/senthilrch
92+
$ git clone https://github.com/senthilrch/kube-fledged.git $HOME/src/github.com/senthilrch/kube-fledged
93+
$ cd $HOME/src/github.com/senthilrch/kube-fledged
94+
```
95+
96+
- Deploy the operator to a separate namespace called "operators"
97+
98+
```
99+
$ sed -i "s|OPERATOR_NAMESPACE|operators|g" deploy/kubefledged-operator/deploy/service_account.yaml
100+
$ sed -i "s|OPERATOR_NAMESPACE|operators|g" deploy/kubefledged-operator/deploy/clusterrole_binding.yaml
101+
$ sed -i "s|OPERATOR_NAMESPACE|operators|g" deploy/kubefledged-operator/deploy/operator.yaml
102+
$ kubectl create namespace operators
103+
$ kubectl create -f deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_kubefledgeds_crd.yaml
104+
$ kubectl create -f deploy/kubefledged-operator/deploy/service_account.yaml
105+
$ kubectl create -f deploy/kubefledged-operator/deploy/clusterrole.yaml
106+
$ kubectl create -f deploy/kubefledged-operator/deploy/clusterrole_binding.yaml
107+
$ kubectl create -f deploy/kubefledged-operator/deploy/operator.yaml
108+
```
109+
110+
- Deploy _kube-fledged_ to a separate namespace called "kube-fledged"
111+
112+
```
113+
$ sed -i "s|OPERATOR_NAMESPACE|operators|g" deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_v1alpha1_kubefledged_cr.yaml
114+
$ sed -i "s|KUBEFLEDGED_NAMESPACE|kube-fledged|g" deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_v1alpha1_kubefledged_cr.yaml
115+
$ kubectl create namespace kube-fledged
116+
$ kubectl create -f deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_v1alpha1_kubefledged_cr.yaml
117+
```
118+
119+
- Verify if _kube-fledged_ deployed successfully
120+
121+
```
122+
$ kubectl get pods -n kube-fledged -l app.kubernetes.io/name=kubefledged
50123
$ kubectl logs -f <pod_name_obtained_from_above_command> -n kube-fledged
51124
$ kubectl get imagecaches -n kube-fledged (Output should be: 'No resources found')
52125
```
53126

54127
## Build and Deploy
55128

56-
These instructions will help you build _kube-fledged_ from source and deploy it on a kubernetes cluster.
129+
These instructions will help you build _kube-fledged_ from source and deploy it to a separate namespace called "kube-fledged". If you need to deploy it to a different namespace, edit the namespace field of the manifests in "kube-fledged/deploy" accordingly.
57130

58131
### Build
59132

@@ -75,29 +148,29 @@ These instructions will help you build _kube-fledged_ from source and deploy it
75148
- Build and push the docker images to registry (e.g. Docker hub)
76149

77150
```
78-
$ export FLEDGED_IMAGE_NAME=<your_docker_hub_username>/fledged:<your_tag>
79-
$ export FLEDGED_DOCKER_CLIENT_IMAGE_NAME=<your_docker_hub_username>/fledged-docker-client:<your_tag>
80-
$ export DOCKER_VERSION=<docker_version_used_for_building_docker_client_image>
151+
$ export RELEASE_VERSION=<your_tag>
152+
$ export FLEDGED_IMAGE_REPO=<your_docker_hub_username>/fledged
153+
$ export FLEDGED_DOCKER_CLIENT_IMAGE_REPO=<your_docker_hub_username>/fledged-docker-client
81154
$ docker login -u <username> -p <password>
82-
$ make fledged-image && make client-image && make push-image
155+
$ make fledged-image && make client-image && make push-images
83156
```
84157

85158
### Deploy
86159

87160
_Note:- You need to have 'cluster-admin' privileges to deploy_
88161

89-
- All manifests required for deploying _kube-fledged_ are present inside 'kube-fledged/deploy'. These steps deploy _kube-fledged_ into a separate namespace called "kube-fledged" with default configuration flags. Edit "fledged-deployment.yaml".
162+
- All manifests required for deploying _kube-fledged_ are present in 'kube-fledged/deploy' directory. Edit "kubefledged-deployment.yaml".
90163

91164
Set "image" to "<your_docker_hub_username>/fledged:<your_tag>"
92165

93166
```
94167
image: <your_docker_hub_username>/fledged:<your_tag>
95168
```
96169

97-
- If you pushed the image to a private repository, add 'imagePullSecrets' to the end of "fledged-deployment.yaml". Refer to kubernetes documentation on [Specifying ImagePullSecrets on a Pod](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod). The secret <your_registry_key> should be created in "kube-fledged" namespace.
170+
- If you pushed the image to a private repository, add 'imagePullSecrets' to the end of "kubefledged-deployment.yaml". Refer to kubernetes documentation on [Specifying ImagePullSecrets on a Pod](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod). The secret <your_registry_key> should be created in "kube-fledged" namespace.
98171

99172
```
100-
serviceAccountName: fledged
173+
serviceAccountName: kubefledged
101174
imagePullSecrets:
102175
- name: <your_registry_key>
103176
```
@@ -111,7 +184,7 @@ _Note:- You need to have 'cluster-admin' privileges to deploy_
111184
- Verify if _kube-fledged_ deployed successfully
112185

113186
```
114-
$ kubectl get pods -n kube-fledged -l app=fledged
187+
$ kubectl get pods -n kube-fledged -l app=kubefledged
115188
$ kubectl logs -f <pod_name_obtained_from_above_command> -n kube-fledged
116189
$ kubectl get imagecaches -n kube-fledged (Output should be: 'No resources found')
117190
```
@@ -122,7 +195,7 @@ _kube-fledged_ provides APIs to perform CRUD operations on image cache. These A
122195

123196
### Create image cache
124197

125-
Refer to sample image cache manifest in "deploy/fledged-imagecache.yaml". Edit it as per your needs before creating image cache. If images are in private repositories requiring credentials to pull, add "imagePullSecrets" to the end.
198+
Refer to sample image cache manifest in "deploy/kubefledged-imagecache.yaml". Edit it as per your needs before creating image cache. If images are in private repositories requiring credentials to pull, add "imagePullSecrets" to the end.
126199

127200
```
128201
imagePullSecrets:
@@ -132,7 +205,7 @@ Refer to sample image cache manifest in "deploy/fledged-imagecache.yaml". Edit i
132205
Create the image cache using kubectl. Verify successful creation
133206

134207
```
135-
$ kubectl create -f deploy/fledged-imagecache.yaml
208+
$ kubectl create -f deploy/kubefledged-imagecache.yaml
136209
$ kubectl get imagecaches -n kube-fledged
137210
```
138211

build/Dockerfile.docker_client

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM alpine:3.10
15+
ARG ALPINE_VERSION
16+
FROM alpine:$ALPINE_VERSION
1617

1718
RUN apk add --no-cache bash curl openssh-client
1819

0 commit comments

Comments
 (0)