Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR #2 for v0.10.0 #185

Merged
merged 17 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 7 additions & 69 deletions .github/workflows/build-kube-fledged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:

- name: Install dependencies
run: |
go get -u golang.org/x/lint/golint
go install golang.org/x/lint/golint@latest

- name: Run verify scripts
run: |
Expand Down Expand Up @@ -170,74 +170,12 @@ jobs:
push: ${{ inputs.push_image }}
tags: ${{ inputs.operator_image_repo }}:${{ inputs.release_version }},${{ inputs.operator_image_repo }}:latest

e2e_test_kube_fledged:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ inputs.golang_version }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build kubefledged-controller image
uses: docker/build-push-action@v2
with:
context: .
file: ${{ inputs.dockerfile_controller }}
build-args: |
ALPINE_VERSION=${{ inputs.alpine_version }}
GOLANG_VERSION=${{ inputs.golang_version }}
platforms: linux/amd64
push: false
load: true
tags: ${{ inputs.controller_image_repo }}:${{ inputs.release_version }}

- name: Build kubefledged-webhook-server image
uses: docker/build-push-action@v2
with:
context: .
file: ${{ inputs.dockerfile_webhook_server }}
build-args: |
ALPINE_VERSION=${{ inputs.alpine_version }}
GOLANG_VERSION=${{ inputs.golang_version }}
platforms: linux/amd64
push: false
load: true
tags: ${{ inputs.webhook_server_image_repo }}:${{ inputs.release_version }}

- name: Build kubefledged-cri-client image
uses: docker/build-push-action@v2
with:
context: .
file: ${{ inputs.dockerfile_cri_client }}
build-args: |
ALPINE_VERSION=${{ inputs.alpine_version }}
CRICTL_VERSION=${{ inputs.crictl_version }}
DOCKER_VERSION=${{ inputs.docker_version }}
platforms: linux/amd64
push: false
load: true
tags: ${{ inputs.crictl_image_repo }}:${{ inputs.release_version }}

- name: Build kubefledged-operator image
uses: docker/build-push-action@v2
with:
context: ./deploy/kubefledged-operator
file: ${{ inputs.dockerfile_operator }}
build-args: |
OPERATORSDK_VERSION=${{ inputs.operatorsdk_version }}
platforms: linux/amd64
push: false
load: true
tags: ${{ inputs.operator_image_repo }}:${{ inputs.release_version }}

- name: E2e test
env:
IMAGE_TAG: ${{ inputs.release_version }}
run: make e2e-test

run: |
docker pull ${{ inputs.controller_image_repo }}:${{ inputs.release_version }}
docker pull ${{ inputs.webhook_server_image_repo }}:${{ inputs.release_version }}
docker pull ${{ inputs.crictl_image_repo }}:${{ inputs.release_version }}
docker pull ${{ inputs.operator_image_repo }}:${{ inputs.release_version }}
go test -v ./e2etest
38 changes: 19 additions & 19 deletions .github/workflows/caller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ jobs:
if: github.event_name == 'push' && github.ref_type == 'branch' && github.ref_name == 'master'
uses: ./.github/workflows/build-kube-fledged.yml
with:
alpine_version: 3.15.4
alpine_version: 3.16.2
crictl_version: v1.25.0
docker_version: 20.10.20
golang_version: 1.19.2
operatorsdk_version: v1.24.1
release_version: v0.10.0
controller_image_repo: docker.io/senthilrch/kubefledged-controller
crictl_image_repo: docker.io/senthilrch/kubefledged-cri-client
crictl_version: v1.23.0
docker_version: 20.10.9
dockerfile_controller: build/Dockerfile.controller
dockerfile_cri_client: build/Dockerfile.cri_client
dockerfile_operator: deploy/kubefledged-operator/build/Dockerfile
dockerfile_webhook_server: build/Dockerfile.webhook_server
golang_version: 1.18.1
operator_image_repo: docker.io/senthilrch/kubefledged-operator
operator_target_platforms: linux/amd64,linux/arm64
operatorsdk_version: v1.19.1
push_image: true
release_version: v0.10.0
target_platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
webhook_server_image_repo: docker.io/senthilrch/kubefledged-webhook-server
secrets:
Expand All @@ -35,21 +35,21 @@ jobs:
if: github.event_name == 'push' && github.ref_type == 'branch' && github.ref_name == 'develop'
uses: ./.github/workflows/build-kube-fledged.yml
with:
alpine_version: 3.15.0
alpine_version: 3.16.2
crictl_version: v1.25.0
docker_version: 20.10.20
golang_version: 1.19.2
operatorsdk_version: v1.24.1
release_version: v0.10.0
controller_image_repo: docker.io/senthilrch/kubefledged-controller
crictl_image_repo: docker.io/senthilrch/kubefledged-cri-client
crictl_version: v1.23.0
docker_version: 20.10.9
dockerfile_controller: build/Dockerfile.controller
dockerfile_cri_client: build/Dockerfile.cri_client
dockerfile_operator: deploy/kubefledged-operator/build/Dockerfile
dockerfile_webhook_server: build/Dockerfile.webhook_server
golang_version: 1.17.7
operator_image_repo: docker.io/senthilrch/kubefledged-operator
operator_target_platforms: linux/amd64,linux/arm64
operatorsdk_version: v1.18.0
operator_target_platforms: linux/amd64
push_image: true
release_version: v0.10.0
target_platforms: linux/amd64
webhook_server_image_repo: docker.io/senthilrch/kubefledged-webhook-server
secrets:
Expand All @@ -59,20 +59,20 @@ jobs:
if: github.event_name == 'pull_request'
uses: ./.github/workflows/build-kube-fledged.yml
with:
alpine_version: 3.15.0
alpine_version: 3.16.2
crictl_version: v1.25.0
docker_version: 20.10.20
golang_version: 1.19.2
operatorsdk_version: v1.24.1
release_version: v0.10.0
controller_image_repo: docker.io/senthilrch/kubefledged-controller
crictl_image_repo: docker.io/senthilrch/kubefledged-cri-client
crictl_version: v1.23.0
docker_version: 20.10.9
dockerfile_controller: build/Dockerfile.controller
dockerfile_cri_client: build/Dockerfile.cri_client
dockerfile_operator: deploy/kubefledged-operator/build/Dockerfile
dockerfile_webhook_server: build/Dockerfile.webhook_server
golang_version: 1.17.7
operator_image_repo: docker.io/senthilrch/kubefledged-operator
operator_target_platforms: linux/amd64
operatorsdk_version: v1.18.0
push_image: false
release_version: v0.10.0
target_platforms: linux/amd64
webhook_server_image_repo: docker.io/senthilrch/kubefledged-webhook-server
53 changes: 21 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,28 @@ ifndef OPERATOR_IMAGE_REPO
OPERATOR_IMAGE_REPO=docker.io/senthilrch/kubefledged-operator
endif

ifndef RELEASE_VERSION
RELEASE_VERSION=v0.10.0
ifndef ALPINE_VERSION
ALPINE_VERSION=3.16.2
endif

ifndef DOCKER_VERSION
DOCKER_VERSION=20.10.9
ifndef CRICTL_VERSION
CRICTL_VERSION=v1.25.0
endif

ifndef CRICTL_VERSION
CRICTL_VERSION=v1.23.0
ifndef DOCKER_VERSION
DOCKER_VERSION=20.10.20
endif

ifndef GOLANG_VERSION
GOLANG_VERSION=1.17.7
GOLANG_VERSION=1.19.2
endif

ifndef ALPINE_VERSION
ALPINE_VERSION=3.15.0
ifndef OPERATORSDK_VERSION
OPERATORSDK_VERSION=v1.24.1
endif

ifndef OPERATORSDK_VERSION
OPERATORSDK_VERSION=v1.18.0
ifndef RELEASE_VERSION
RELEASE_VERSION=v0.10.0
endif

ifndef TARGET_PLATFORMS
Expand Down Expand Up @@ -195,8 +195,6 @@ deploy-using-yaml:
kubectl apply -f deploy/kubefledged-clusterrolebinding-controller.yaml
kubectl apply -f deploy/kubefledged-deployment-controller.yaml
kubectl rollout status deployment kubefledged-controller -n kube-fledged --watch

deploy-webhook-server-using-yaml:
-kubectl delete validatingwebhookconfigurations -l app=kubefledged
kubectl apply -f deploy/kubefledged-validatingwebhook.yaml
-kubectl delete deploy -l app=kubefledged,kubefledged=kubefledged-webhook-server
Expand All @@ -206,27 +204,30 @@ deploy-webhook-server-using-yaml:
kubectl apply -f deploy/kubefledged-deployment-webhook-server.yaml
kubectl apply -f deploy/kubefledged-service-webhook-server.yaml
kubectl rollout status deployment kubefledged-webhook-server -n kube-fledged --watch
kubectl get pods -n kube-fledged

deploy-using-operator:
# Create the namespace
-kubectl create namespace ${KUBEFLEDGED_NAMESPACE}
# Deploy the operator
sed -i "s|{{KUBEFLEDGED_NAMESPACE}}|${KUBEFLEDGED_NAMESPACE}|g" deploy/kubefledged-operator/deploy/service_account.yaml
sed -i "s|{{KUBEFLEDGED_NAMESPACE}}|${KUBEFLEDGED_NAMESPACE}|g" deploy/kubefledged-operator/deploy/clusterrole_binding.yaml
sed -i "s|{{KUBEFLEDGED_NAMESPACE}}|${KUBEFLEDGED_NAMESPACE}|g" deploy/kubefledged-operator/deploy/operator.yaml
sed -i '' "s|{{KUBEFLEDGED_NAMESPACE}}|${KUBEFLEDGED_NAMESPACE}|g" deploy/kubefledged-operator/deploy/service_account.yaml
sed -i '' "s|{{KUBEFLEDGED_NAMESPACE}}|${KUBEFLEDGED_NAMESPACE}|g" deploy/kubefledged-operator/deploy/clusterrole_binding.yaml
sed -i '' "s|{{KUBEFLEDGED_NAMESPACE}}|${KUBEFLEDGED_NAMESPACE}|g" deploy/kubefledged-operator/deploy/operator.yaml
kubectl apply -f deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_kubefledgeds_crd.yaml
kubectl apply -f deploy/kubefledged-operator/deploy/service_account.yaml
kubectl apply -f deploy/kubefledged-operator/deploy/clusterrole.yaml
kubectl apply -f deploy/kubefledged-operator/deploy/clusterrole_binding.yaml
kubectl apply -f deploy/kubefledged-operator/deploy/operator.yaml
# Deploy kube-fledged
sed -i "s|{{KUBEFLEDGED_NAMESPACE}}|${KUBEFLEDGED_NAMESPACE}|g" deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml
sed -i '' "s|{{KUBEFLEDGED_NAMESPACE}}|${KUBEFLEDGED_NAMESPACE}|g" deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml
kubectl rollout status deployment kubefledged-operator -n ${KUBEFLEDGED_NAMESPACE} --watch
kubectl apply -f deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml

deploy-webhook-server-using-operator:
sed -i "s|enable: false|enable: true|g" deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml
sed -i '' "s|enable: false|enable: true|g" deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml
kubectl apply -f deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml
# Wait for the controller and webhook-server
kubectl rollout status deployment kube-fledged-controller -n ${KUBEFLEDGED_NAMESPACE} --watch
kubectl rollout status deployment kube-fledged-webhook-server -n ${KUBEFLEDGED_NAMESPACE} --watch
kubectl get pods -n ${KUBEFLEDGED_NAMESPACE}

update:
kubectl scale deployment kubefledged-controller --replicas=0 -n kube-fledged
Expand All @@ -242,14 +243,6 @@ remove-kubefledged:
-kubectl delete crd -l app=kubefledged
-kubectl delete validatingwebhookconfigurations -l app=kubefledged

remove-webhook-server:
-kubectl delete validatingwebhookconfigurations -l app=kubefledged
-kubectl delete deploy -l app=kubefledged,kubefledged=kubefledged-webhook-server -n kube-fledged
-kubectl delete service -l app=kubefledged,kubefledged=kubefledged-webhook-server -n kube-fledged
-kubectl delete clusterrolebinding -l app=kubefledged,kubefledged=kubefledged-webhook-server
-kubectl delete clusterrole -l app=kubefledged,kubefledged=kubefledged-webhook-server
-kubectl delete serviceaccount -l app=kubefledged,kubefledged=kubefledged-webhook-server -n kube-fledged

remove-kubefledged-and-operator:
# Remove kubefledged
-kubectl delete -f deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml
Expand All @@ -266,10 +259,6 @@ remove-kubefledged-and-operator:
-git checkout deploy/kubefledged-operator/deploy/clusterrole_binding.yaml
-git checkout deploy/kubefledged-operator/deploy/service_account.yaml

remove-webhook-server-using-operator:
sed -i "s|enable: true|enable: false|g" deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml
kubectl apply -f deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml

.PHONY: e2e-test
e2e-test:
@go test -v ./e2etest
38 changes: 6 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ These instructions install _kube-fledged_ to a separate namespace called "kube-f
- Clone the source code repository

```
$ mkdir -p $HOME/src/github.com/senthilrch
$ git clone https://github.com/senthilrch/kube-fledged.git $HOME/src/github.com/senthilrch/kube-fledged
$ cd $HOME/src/github.com/senthilrch/kube-fledged
$ git clone https://github.com/senthilrch/kube-fledged.git $HOME/kube-fledged
$ cd $HOME/kube-fledged
```

- Deploy _kube-fledged_ to the cluster
Expand All @@ -87,12 +86,6 @@ These instructions install _kube-fledged_ to a separate namespace called "kube-f
$ kubectl get imagecaches -n kube-fledged (Output should be: 'No resources found')
```

- Optional: Deploy _kube-fledged webhook server_ to the cluster. This component enables validating the ImageCache CR.

```
$ make deploy-webhook-server-using-yaml
```

## Quick Install using Helm chart

- Create the namespace where kube-fledged will be installed
Expand All @@ -112,12 +105,6 @@ These instructions install _kube-fledged_ to a separate namespace called "kube-f
$ helm install --verify kube-fledged kubefledged-charts/kube-fledged -n ${KUBEFLEDGED_NAMESPACE} --wait
```

- Optional: Verify and install kube-fledged webhook server. This component enables validating the ImageCache CR.

```
$ helm upgrade --verify kube-fledged kubefledged-charts/kube-fledged -n ${KUBEFLEDGED_NAMESPACE} --set webhookServer.enable=true --wait
```

## Quick Install using Helm operator

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)
Expand All @@ -143,12 +130,6 @@ These instructions install _kube-fledged_ to a separate namespace called "kube-f
$ kubectl get imagecaches -n kube-fledged (Output should be: 'No resources found')
```

- Optional: Deploy _kube-fledged webhook server_ to the cluster. This component enables validating the ImageCache CR.

```
$ make deploy-webhook-server-using-operator
```

## Helm chart parameters

Parameters of the helm chart are documented [here](docs/helm-parameters.md)
Expand All @@ -162,9 +143,8 @@ These instructions will help you build _kube-fledged_ from source and deploy it
- Clone the source code repository

```
$ mkdir -p $HOME/src/github.com/senthilrch
$ git clone https://github.com/senthilrch/kube-fledged.git $HOME/src/github.com/senthilrch/kube-fledged
$ cd $HOME/src/github.com/senthilrch/kube-fledged
$ git clone https://github.com/senthilrch/kube-fledged.git $HOME/kube-fledged
$ cd $HOME/kube-fledged
```

- If you are behind a proxy, export the following ENV variables (UPPER case)
Expand Down Expand Up @@ -303,14 +283,6 @@ $ helm delete kube-fledged -n ${KUBEFLEDGED_NAMESPACE} (if you deployed using He
$ make remove-kubefledged-and-operator (if you deployed using Helm Operator)
```

Note: To remove the _kube-fledged webhook server_ alone.

```
$ make remove-webhook-server (if you deployed using YAML manifests)
$ helm upgrade kube-fledged deploy/kubefledged-operator/helm-charts/kubefledged -n ${KUBEFLEDGED_NAMESPACE} --set webhookServer.enable=false --wait --debug (if you deployed using Helm chart)
$ make remove-webhook-server-using-operator (if you deployed using Helm Operator)
```

## How it works

Kubernetes allows developers to extend the kubernetes api via [Custom Resources](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/). _kube-fledged_ defines a custom resource of kind “ImageCache” and implements a custom controller (named _kubefledged-controller_). _kubefledged-controller_ does the heavy-lifting for managing image cache. Users can use kubectl commands for creation and deletion of ImageCache resources.
Expand All @@ -322,6 +294,8 @@ For more detailed description, go through _kube-fledged's_ [design proposal](doc

## Configuration Flags for Kubefledged Controller

`--cri-socket-path:` path to the cri socket on the node e.g. /run/containerd/containerd.sock (default: /var/run/docker.sock, /run/containerd/containerd.sock, /var/run/crio/crio.sock)

`--image-cache-refresh-frequency:` The image cache is refreshed periodically to ensure the cache is up to date. Setting this flag to "0s" will disable refresh. default "15m"

`--image-delete-job-host-network:` Whether the pod for the image delete job should be run with 'HostNetwork: true'. Default value: false.
Expand Down
5 changes: 3 additions & 2 deletions cmd/controller/app/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ func NewController(
serviceAccountName string,
imageDeleteJobHostNetwork bool,
jobPriorityClassName string,
canDeleteJob bool) *Controller {
canDeleteJob bool,
criSocketPath string) *Controller {

runtime.Must(fledgedscheme.AddToScheme(scheme.Scheme))
glog.V(4).Info("Creating event broadcaster")
Expand All @@ -125,7 +126,7 @@ func NewController(
imageManager, _ := images.NewImageManager(controller.workqueue, controller.imageworkqueue,
controller.kubeclientset, controller.fledgedNameSpace, imagePullDeadlineDuration,
criClientImage, busyboxImage, imagePullPolicy, serviceAccountName, imageDeleteJobHostNetwork,
jobPriorityClassName, canDeleteJob)
jobPriorityClassName, canDeleteJob, criSocketPath)
controller.imageManager = imageManager

glog.Info("Setting up event handlers")
Expand Down
Loading