Skip to content

Commit

Permalink
Merge f03bf33 into bfc4478
Browse files Browse the repository at this point in the history
  • Loading branch information
bhuvanessr committed May 28, 2020
2 parents bfc4478 + f03bf33 commit d3e53da
Show file tree
Hide file tree
Showing 20 changed files with 1,029 additions and 315 deletions.
434 changes: 233 additions & 201 deletions Makefile

Large diffs are not rendered by default.

17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ of images and onto which worker nodes those images should be cached (i.e. pre-pu
_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.

## Table of contents
<!-- https://github.com/thlorenz/doctoc -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

Expand All @@ -34,6 +35,7 @@ _kube-fledged_ provides CRUD APIs to manage the lifecycle of the image cache, an
- [Remove kube-fledged](#remove-kube-fledged)
- [How it works](#how-it-works)
- [Configuration Flags](#configuration-flags)
- [Supported Container Runtimes](#supported-container-runtimes)
- [Supported Platforms](#supported-platforms)
- [Built With](#built-with)
- [Contributing](#contributing)
Expand All @@ -52,8 +54,7 @@ _kube-fledged_ provides CRUD APIs to manage the lifecycle of the image cache, an

- A functioning kubernetes cluster (v1.9 or above). It could be a simple development cluster like minikube or a large production cluster.
- All master and worker nodes having the ["kubernetes.io/hostname"](https://kubernetes.io/docs/reference/kubernetes-api/labels-annotations-taints/#kubernetes-io-hostname) label.
- Supported container runtimes: docker, containerd, cri-o
- git, make, go, docker and kubectl installed on a local linux machine. kubectl configured properly to access the cluster.
- git, make, go, docker engine (>= 19.03) and kubectl installed on a local linux machine. kubectl configured properly to access the cluster.

## Quick Install using YAML manifests

Expand All @@ -70,7 +71,7 @@ These instructions install _kube-fledged_ to a separate namespace called "kube-f
- Deploy _kube-fledged_ to the cluster

```
$ make deploy
$ make deploy-using-yaml
```

- Verify if _kube-fledged_ deployed successfully
Expand Down Expand Up @@ -133,9 +134,9 @@ These instructions will help you build _kube-fledged_ from source and deploy it
```
$ export RELEASE_VERSION=<your_tag>
$ export FLEDGED_IMAGE_REPO=<your_docker_hub_username>/fledged
$ export FLEDGED_DOCKER_CLIENT_IMAGE_REPO=<your_docker_hub_username>/fledged-docker-client
$ docker login -u <username> -p <password>
$ make fledged-image && make client-image && make push-images
$ export DOCKER_CLI_EXPERIMENTAL=enabled
$ sudo make install-buildx && sudo make fledged-image
```

### Deploy
Expand Down Expand Up @@ -267,6 +268,12 @@ For more detailed description, go through _kube-fledged's_ [design proposal](doc

`--stderrthreshold:` Log level. set the value of this flag to INFO

## Supported Container Runtimes

- docker
- containerd
- cri-o

## Supported Platforms

- linux/amd64
Expand Down
60 changes: 30 additions & 30 deletions build/Dockerfile.fledged
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# Copyright 2018 The kube-fledged authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ARG GOLANG_VERSION
ARG ALPINE_VERSION

FROM golang:$GOLANG_VERSION AS builder
LABEL stage=builder
ARG GIT_BRANCH
RUN mkdir -p /go/src/github.com/senthilrch && \
git clone --depth=1 --single-branch --branch=$GIT_BRANCH https://github.com/senthilrch/kube-fledged /go/src/github.com/senthilrch/kube-fledged && \
cd /go/src/github.com/senthilrch/kube-fledged && \
CGO_ENABLED=0 go build -o build/fledged -ldflags '-s -w -extldflags "-static"' cmd/fledged.go

FROM alpine:$ALPINE_VERSION
LABEL maintainer="senthilrch <senthilrch@gmail.com>"
COPY --from=builder /go/src/github.com/senthilrch/kube-fledged/build/fledged /opt/bin/fledged
RUN chmod 755 /opt/bin/fledged
ENTRYPOINT ["/opt/bin/fledged"]
# Copyright 2018 The kube-fledged authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ARG GOLANG_VERSION
ARG ALPINE_VERSION
FROM golang:$GOLANG_VERSION AS builder
LABEL stage=builder
ARG GIT_BRANCH
RUN mkdir -p /go/src/github.com/senthilrch && \
git clone --depth=1 --single-branch --branch=$GIT_BRANCH https://github.com/senthilrch/kube-fledged.git /go/src/github.com/senthilrch/kube-fledged && \
cd /go/src/github.com/senthilrch/kube-fledged && \
CGO_ENABLED=0 go build -o build/fledged -ldflags '-s -w -extldflags "-static"' cmd/fledged/main.go
FROM alpine:$ALPINE_VERSION
LABEL maintainer="senthilrch <senthilrch@gmail.com>"
COPY --from=builder /go/src/github.com/senthilrch/kube-fledged/build/fledged /opt/bin/fledged
RUN chmod 755 /opt/bin/fledged
ENTRYPOINT ["/opt/bin/fledged"]
30 changes: 30 additions & 0 deletions build/Dockerfile.webhook_server
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2018 The kube-fledged authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ARG GOLANG_VERSION
ARG ALPINE_VERSION

FROM golang:$GOLANG_VERSION AS builder
LABEL stage=builder
ARG GIT_BRANCH
RUN mkdir -p /go/src/github.com/senthilrch && \
git clone --depth=1 --single-branch --branch=$GIT_BRANCH https://github.com/senthilrch/kube-fledged.git /go/src/github.com/senthilrch/kube-fledged && \
cd /go/src/github.com/senthilrch/kube-fledged && \
CGO_ENABLED=0 go build -o build/fledged-webhook-server -ldflags '-s -w -extldflags "-static"' cmd/webhook-server/main.go

FROM alpine:$ALPINE_VERSION
LABEL maintainer="senthilrch <senthilrch@gmail.com>"
COPY --from=builder /go/src/github.com/senthilrch/kube-fledged/build/fledged-webhook-server /opt/bin/fledged-webhook-server
RUN chmod 755 /opt/bin/fledged-webhook-server
ENTRYPOINT ["/opt/bin/fledged-webhook-server"]
23 changes: 23 additions & 0 deletions build/Dockerfile.webhook_server_dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2018 The kube-fledged authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ARG ALPINE_VERSION

FROM alpine:$ALPINE_VERSION
LABEL maintainer="senthilrch <senthilrch@gmail.com>"

COPY fledged-webhook-server /opt/bin/fledged-webhook-server
RUN chmod 755 /opt/bin/fledged-webhook-server

ENTRYPOINT ["/opt/bin/fledged-webhook-server"]
44 changes: 0 additions & 44 deletions cmd/app/controller.go → cmd/fledged/app/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,20 +452,6 @@ func (c *Controller) syncHandler(wqKey images.WorkQueueKey) error {
return err
}

err = validateCacheSpec(c, imageCache)
if err != nil {
status.Status = fledgedv1alpha1.ImageCacheActionStatusFailed
status.Reason = fledgedv1alpha1.ImageCacheReasonCacheSpecValidationFailed
status.Message = err.Error()

if err := c.updateImageCacheStatus(imageCache, status); err != nil {
glog.Errorf("Error updating imagecache status to %s: %v", status.Status, err)
return err
}

return err
}

if wqKey.WorkType == images.ImageCacheUpdate && wqKey.OldImageCache == nil {
status.Status = fledgedv1alpha1.ImageCacheActionStatusFailed
status.Reason = fledgedv1alpha1.ImageCacheReasonOldImageCacheNotFound
Expand All @@ -479,36 +465,6 @@ func (c *Controller) syncHandler(wqKey images.WorkQueueKey) error {
return fmt.Errorf("%s: %s", fledgedv1alpha1.ImageCacheReasonOldImageCacheNotFound, fledgedv1alpha1.ImageCacheMessageOldImageCacheNotFound)
}

if wqKey.WorkType == images.ImageCacheUpdate {
if len(wqKey.OldImageCache.Spec.CacheSpec) != len(imageCache.Spec.CacheSpec) {
status.Status = fledgedv1alpha1.ImageCacheActionStatusFailed
status.Reason = fledgedv1alpha1.ImageCacheReasonCacheSpecValidationFailed
status.Message = fledgedv1alpha1.ImageCacheMessageNotSupportedUpdates

if err = c.updateImageCacheSpecAndStatus(imageCache, wqKey.OldImageCache.Spec, status); err != nil {
glog.Errorf("Error updating imagecache spec and status to %s: %v", status.Status, err)
return err
}
glog.Errorf("%s: %s", fledgedv1alpha1.ImageCacheReasonCacheSpecValidationFailed, "Mismatch in no. of image lists")
return fmt.Errorf("%s: %s", fledgedv1alpha1.ImageCacheReasonCacheSpecValidationFailed, "Mismatch in no. of image lists")
}

for i := range wqKey.OldImageCache.Spec.CacheSpec {
if !reflect.DeepEqual(wqKey.OldImageCache.Spec.CacheSpec[i].NodeSelector, imageCache.Spec.CacheSpec[i].NodeSelector) {
status.Status = fledgedv1alpha1.ImageCacheActionStatusFailed
status.Reason = fledgedv1alpha1.ImageCacheReasonCacheSpecValidationFailed
status.Message = fledgedv1alpha1.ImageCacheMessageNotSupportedUpdates

if err = c.updateImageCacheSpecAndStatus(imageCache, wqKey.OldImageCache.Spec, status); err != nil {
glog.Errorf("Error updating imagecache spec and status to %s: %v", status.Status, err)
return err
}
glog.Errorf("%s: %s", fledgedv1alpha1.ImageCacheReasonCacheSpecValidationFailed, "Mismatch in node selector")
return fmt.Errorf("%s: %s", fledgedv1alpha1.ImageCacheReasonCacheSpecValidationFailed, "Mismatch in node selector")
}
}
}

cacheSpec := imageCache.Spec.CacheSpec
glog.V(4).Infof("cacheSpec: %+v", cacheSpec)
var nodes []*corev1.Node
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion cmd/fledged.go → cmd/fledged/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

// Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters).
// _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"github.com/senthilrch/kube-fledged/cmd/app"
"github.com/senthilrch/kube-fledged/cmd/fledged/app"
clientset "github.com/senthilrch/kube-fledged/pkg/client/clientset/versioned"
informers "github.com/senthilrch/kube-fledged/pkg/client/informers/externalversions"
"github.com/senthilrch/kube-fledged/pkg/signals"
Expand All @@ -40,6 +40,7 @@ var (
dockerClientImage string
imagePullPolicy string
fledgedNameSpace string
webhookServerPort int
)

func main() {
Expand Down
Loading

0 comments on commit d3e53da

Please sign in to comment.