Skip to content

Commit 269ce1d

Browse files
authored
Merge pull request #81 from senthilrch/develop
PR for kube-fledged v0.8.1
2 parents 163cd80 + f18cd88 commit 269ce1d

39 files changed

+835
-377
lines changed

Makefile

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ifndef OPERATOR_IMAGE_REPO
4343
endif
4444

4545
ifndef RELEASE_VERSION
46-
RELEASE_VERSION=v0.8.0
46+
RELEASE_VERSION=v0.8.1
4747
endif
4848

4949
ifndef DOCKER_VERSION
@@ -63,7 +63,7 @@ ifndef ALPINE_VERSION
6363
endif
6464

6565
ifndef OPERATORSDK_VERSION
66-
OPERATORSDK_VERSION=v1.7.2
66+
OPERATORSDK_VERSION=v1.9.0
6767
endif
6868

6969
ifndef TARGET_PLATFORMS
@@ -193,17 +193,17 @@ hack:
193193

194194
deploy-using-yaml:
195195
-kubectl apply -f deploy/kubefledged-namespace.yaml
196-
bash deploy/webhook-create-signed-cert.sh
197-
bash deploy/webhook-patch-ca-bundle.sh
198196
kubectl apply -f deploy/kubefledged-crd.yaml
199197
kubectl apply -f deploy/kubefledged-serviceaccount.yaml
200198
kubectl apply -f deploy/kubefledged-clusterrole.yaml
201199
kubectl apply -f deploy/kubefledged-clusterrolebinding.yaml
200+
-kubectl delete validatingwebhookconfigurations -l app=kubefledged
201+
kubectl apply -f deploy/kubefledged-validatingwebhook.yaml
202202
kubectl apply -f deploy/kubefledged-deployment-webhook-server.yaml
203-
kubectl rollout status deployment kubefledged-webhook-server -n kube-fledged --watch
204-
kubectl apply -f deploy/kubefledged-deployment-controller.yaml
205203
kubectl apply -f deploy/kubefledged-service-webhook-server.yaml
206-
kubectl apply -f deploy/kubefledged-validatingwebhook.yaml
204+
kubectl apply -f deploy/kubefledged-deployment-controller.yaml
205+
kubectl rollout status deployment kubefledged-webhook-server -n kube-fledged --watch
206+
kubectl rollout status deployment kubefledged-controller -n kube-fledged --watch
207207

208208
deploy-using-operator:
209209
# Create the namespaces for operator and kubefledged
@@ -213,17 +213,16 @@ deploy-using-operator:
213213
sed -i "s|{{OPERATOR_NAMESPACE}}|${OPERATOR_NAMESPACE}|g" deploy/kubefledged-operator/deploy/service_account.yaml
214214
sed -i "s|{{OPERATOR_NAMESPACE}}|${OPERATOR_NAMESPACE}|g" deploy/kubefledged-operator/deploy/clusterrole_binding.yaml
215215
sed -i "s|{{OPERATOR_NAMESPACE}}|${OPERATOR_NAMESPACE}|g" deploy/kubefledged-operator/deploy/operator.yaml
216-
kubectl apply -f deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_kubefledgeds_crd.yaml
216+
kubectl apply -f deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_kubefledgeds_crd.yaml
217217
kubectl apply -f deploy/kubefledged-operator/deploy/service_account.yaml
218218
kubectl apply -f deploy/kubefledged-operator/deploy/clusterrole.yaml
219219
kubectl apply -f deploy/kubefledged-operator/deploy/clusterrole_binding.yaml
220220
kubectl apply -f deploy/kubefledged-operator/deploy/operator.yaml
221221
# Deploy kube-fledged to a separate namespace
222-
sed -i "s|{{OPERATOR_NAMESPACE}}|${OPERATOR_NAMESPACE}|g" deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_v1alpha2_kubefledged_cr.yaml
223-
sed -i "s|{{KUBEFLEDGED_NAMESPACE}}|${KUBEFLEDGED_NAMESPACE}|g" deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_v1alpha2_kubefledged_cr.yaml
224-
bash deploy/webhook-create-signed-cert.sh --namespace ${KUBEFLEDGED_NAMESPACE}
225-
bash deploy/webhook-patch-ca-bundle.sh
226-
kubectl apply -f deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_v1alpha2_kubefledged_cr.yaml
222+
sed -i "s|{{OPERATOR_NAMESPACE}}|${OPERATOR_NAMESPACE}|g" deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml
223+
sed -i "s|{{KUBEFLEDGED_NAMESPACE}}|${KUBEFLEDGED_NAMESPACE}|g" deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml
224+
kubectl rollout status deployment kubefledged-operator -n kubefledged-operator --watch
225+
kubectl apply -f deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml
227226

228227
update:
229228
kubectl scale deployment kubefledged-controller --replicas=0 -n kube-fledged
@@ -238,21 +237,18 @@ remove-kubefledged:
238237
-kubectl delete -f deploy/kubefledged-clusterrole.yaml
239238
-kubectl delete -f deploy/kubefledged-crd.yaml
240239
-kubectl delete -f deploy/kubefledged-validatingwebhook.yaml
241-
-git checkout deploy/kubefledged-validatingwebhook.yaml
242-
-git checkout deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_v1alpha2_kubefledged_cr.yaml
243240

244241
remove-operator-and-kubefledged:
245242
# Remove kubefledged and the namespace
246-
-kubectl delete -f deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_v1alpha2_kubefledged_cr.yaml
243+
-kubectl delete -f deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_v1alpha2_kubefledged_cr.yaml
244+
-kubectl delete validatingwebhookconfigurations -l app.kubernetes.io/name=kube-fledged
247245
-kubectl delete namespace ${KUBEFLEDGED_NAMESPACE}
248-
-git checkout deploy/kubefledged-validatingwebhook.yaml
249-
-git checkout deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_v1alpha2_kubefledged_cr.yaml
250246
# Remove the kubefledged operator and the namespace
251247
-kubectl delete -f deploy/kubefledged-operator/deploy/operator.yaml
252248
-kubectl delete -f deploy/kubefledged-operator/deploy/clusterrole_binding.yaml
253249
-kubectl delete -f deploy/kubefledged-operator/deploy/clusterrole.yaml
254250
-kubectl delete -f deploy/kubefledged-operator/deploy/service_account.yaml
255-
-kubectl delete -f deploy/kubefledged-operator/deploy/crds/charts.helm.k8s.io_kubefledgeds_crd.yaml
251+
-kubectl delete -f deploy/kubefledged-operator/deploy/crds/charts.helm.kubefledged.io_kubefledgeds_crd.yaml
256252
-kubectl delete namespace ${OPERATOR_NAMESPACE}
257253
-git checkout deploy/kubefledged-operator/deploy/operator.yaml
258254
-git checkout deploy/kubefledged-operator/deploy/clusterrole_binding.yaml

README.md

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ These instructions install _kube-fledged_ to a separate namespace called "kube-f
7979

8080
```
8181
$ kubectl get pods -n kube-fledged -l app=kubefledged
82-
$ kubectl logs -f <pod_name_obtained_from_above_command> -n kube-fledged
8382
$ kubectl get imagecaches -n kube-fledged (Output should be: 'No resources found')
8483
```
8584

@@ -92,26 +91,14 @@ These instructions install _kube-fledged_ to a separate namespace called "kube-f
9291
$ kubectl create namespace ${KUBEFLEDGED_NAMESPACE}
9392
```
9493

95-
- Create secret containing cert/key for kubefledged-webhook-server
96-
97-
```
98-
$ curl -fsSL https://raw.githubusercontent.com/senthilrch/kube-fledged/master/deploy/webhook-create-signed-cert.sh | bash -s -- --namespace ${KUBEFLEDGED_NAMESPACE}
99-
```
100-
101-
- Retrieve the certificate-authoity-data of the kubernetes cluster
102-
103-
```
104-
$ CLUSTER=$(kubectl config view --raw --flatten -o json | jq -r '.contexts[] | select(.name == "'$(kubectl config current-context)'") | .context.cluster')
105-
$ export CA_BUNDLE=$(kubectl config view --raw --flatten -o json | jq -r '.clusters[] | select(.name == "'${CLUSTER}'") | .cluster."certificate-authority-data"')
106-
```
107-
10894
- Verify and install latest version of kube-fledged helm chart
10995

11096
```
11197
$ helm repo add kubefledged-charts https://senthilrch.github.io/kubefledged-charts/
98+
$ helm repo update
11299
$ gpg --keyserver keyserver.ubuntu.com --recv-keys 92D793FA3A6460ED (or) gpg --keyserver pgp.mit.edu --recv-keys 92D793FA3A6460ED
113100
$ gpg --export >~/.gnupg/pubring.gpg
114-
$ helm install --verify kube-fledged kubefledged-charts/kube-fledged -n ${KUBEFLEDGED_NAMESPACE} --set validatingWebhookCABundle=${CA_BUNDLE} --wait
101+
$ helm install --verify kube-fledged kubefledged-charts/kube-fledged -n ${KUBEFLEDGED_NAMESPACE} --wait
115102
```
116103

117104
## Quick Install using Helm operator
@@ -135,8 +122,7 @@ These instructions install _kube-fledged_ to a separate namespace called "kube-f
135122
- Verify if _kube-fledged_ deployed successfully
136123

137124
```
138-
$ kubectl get pods -n kube-fledged -l app.kubernetes.io/name=kubefledged
139-
$ kubectl logs -f <pod_name_obtained_from_above_command> -n kube-fledged
125+
$ kubectl get pods -n kube-fledged -l app.kubernetes.io/name=kube-fledged
140126
$ kubectl get imagecaches -n kube-fledged (Output should be: 'No resources found')
141127
```
142128

@@ -257,15 +243,15 @@ $ kubectl get imagecaches imagecache1 -n kube-fledged -o json
257243
_kube-fledged_ supports both automatic and on-demand refresh of image cache. Auto refresh is enabled using the flag `--image-cache-refresh-frequency:`. To request for an on-demand refresh, run the following command:-
258244

259245
```
260-
$ kubectl annotate imagecaches imagecache1 -n kube-fledged kubefledged.k8s.io/refresh-imagecache=
246+
$ kubectl annotate imagecaches imagecache1 -n kube-fledged kubefledged.io/refresh-imagecache=
261247
```
262248

263249
### Delete image cache
264250

265251
Before you could delete the image cache, you need to purge the images in the cache using the following command. This will remove all cached images from the worker nodes.
266252

267253
```
268-
$ kubectl annotate imagecaches imagecache1 -n kube-fledged kubefledged.k8s.io/purge-imagecache=
254+
$ kubectl annotate imagecaches imagecache1 -n kube-fledged kubefledged.io/purge-imagecache=
269255
```
270256

271257
View the status of purging the image cache. If any failures, such images should be removed manually or you could decide to leave the images in the worker nodes.
@@ -304,8 +290,6 @@ For more detailed description, go through _kube-fledged's_ [design proposal](doc
304290

305291
`--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"
306292

307-
`--cri-client-image:` The image name of the cri client. The cri client is used when deleting images during purging the cache".
308-
309293
`--image-pull-policy:` Image pull policy for pulling images into and refreshing the cache. Possible values are 'IfNotPresent' and 'Always'. Default value is 'IfNotPresent'. Image with no or ":latest" tag are always pulled.
310294

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

cmd/controller/app/controller.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ import (
4545
)
4646

4747
const controllerAgentName = "kubefledged-controller"
48-
const imageCachePurgeAnnotationKey = "kubefledged.k8s.io/purge-imagecache"
49-
const imageCacheRefreshAnnotationKey = "kubefledged.k8s.io/refresh-imagecache"
48+
const imageCachePurgeAnnotationKey = "kubefledged.io/purge-imagecache"
49+
const imageCacheRefreshAnnotationKey = "kubefledged.io/refresh-imagecache"
5050

5151
const (
5252
// SuccessSynced is used as part of the Event 'reason' when a ImageCache is synced
@@ -92,7 +92,8 @@ func NewController(
9292
imageCacheInformer informers.ImageCacheInformer,
9393
imageCacheRefreshFrequency time.Duration,
9494
imagePullDeadlineDuration time.Duration,
95-
dockerClientImage string,
95+
criClientImage string,
96+
busyboxImage string,
9697
imagePullPolicy string) *Controller {
9798

9899
runtime.Must(fledgedscheme.AddToScheme(scheme.Scheme))
@@ -116,7 +117,7 @@ func NewController(
116117
imageCacheRefreshFrequency: imageCacheRefreshFrequency,
117118
}
118119

119-
imageManager, _ := images.NewImageManager(controller.workqueue, controller.imageworkqueue, controller.kubeclientset, controller.fledgedNameSpace, imagePullDeadlineDuration, dockerClientImage, imagePullPolicy)
120+
imageManager, _ := images.NewImageManager(controller.workqueue, controller.imageworkqueue, controller.kubeclientset, controller.fledgedNameSpace, imagePullDeadlineDuration, criClientImage, busyboxImage, imagePullPolicy)
120121
controller.imageManager = imageManager
121122

122123
glog.Info("Setting up event handlers")
@@ -635,10 +636,13 @@ func (c *Controller) syncHandler(wqKey images.WorkQueueKey) error {
635636
}
636637

637638
func (c *Controller) updateImageCacheStatus(imageCache *v1alpha2.ImageCache, status *v1alpha2.ImageCacheStatus) error {
639+
imageCacheCopy, err := c.kubefledgedclientset.KubefledgedV1alpha2().ImageCaches(imageCache.Namespace).Get(context.TODO(), imageCache.Name, metav1.GetOptions{})
640+
if err != nil {
641+
return err
642+
}
638643
// NEVER modify objects from the store. It's a read-only, local cache.
639644
// You can use DeepCopy() to make a deep copy of original object and modify this copy
640645
// Or create a copy manually for better performance
641-
imageCacheCopy := imageCache.DeepCopy()
642646
imageCacheCopy.Status = *status
643647
if imageCacheCopy.Status.Status != v1alpha2.ImageCacheActionStatusProcessing {
644648
completionTime := metav1.Now()
@@ -648,7 +652,7 @@ func (c *Controller) updateImageCacheStatus(imageCache *v1alpha2.ImageCache, sta
648652
// we must use Update instead of UpdateStatus to update the Status block of the ImageCache resource.
649653
// UpdateStatus will not allow changes to the Spec of the resource,
650654
// which is ideal for ensuring nothing other than resource status has been updated.
651-
_, err := c.kubefledgedclientset.KubefledgedV1alpha2().ImageCaches(imageCache.Namespace).Update(context.TODO(), imageCacheCopy, metav1.UpdateOptions{})
655+
_, err = c.kubefledgedclientset.KubefledgedV1alpha2().ImageCaches(imageCache.Namespace).Update(context.TODO(), imageCacheCopy, metav1.UpdateOptions{})
652656
return err
653657
}
654658

cmd/controller/app/controller_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ func newTestController(kubeclientset kubernetes.Interface, fledgedclientset clie
6060
imagecacheInformer := fledgedInformerFactory.Kubefledged().V1alpha2().ImageCaches()
6161
imageCacheRefreshFrequency := time.Second * 0
6262
imagePullDeadlineDuration := time.Second * 5
63-
dockerClientImage := "senthilrch/fledged-docker-client:latest"
63+
criClientImage := "senthilrch/fledged-docker-client:latest"
64+
busyboxImage := "busybox:latest"
6465
imagePullPolicy := "IfNotPresent"
6566

6667
/* startInformers := true
@@ -72,7 +73,7 @@ func newTestController(kubeclientset kubernetes.Interface, fledgedclientset clie
7273
} */
7374

7475
controller := NewController(kubeclientset, fledgedclientset, fledgedNameSpace, nodeInformer, imagecacheInformer,
75-
imageCacheRefreshFrequency, imagePullDeadlineDuration, dockerClientImage, imagePullPolicy)
76+
imageCacheRefreshFrequency, imagePullDeadlineDuration, criClientImage, busyboxImage, imagePullPolicy)
7677
controller.nodesSynced = func() bool { return true }
7778
controller.imageCachesSynced = func() bool { return true }
7879
return controller, nodeInformer, imagecacheInformer

cmd/controller/main.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ import (
3737
var (
3838
imageCacheRefreshFrequency time.Duration
3939
imagePullDeadlineDuration time.Duration
40-
dockerClientImage string
40+
criClientImage string
41+
busyboxImage string
4142
imagePullPolicy string
4243
fledgedNameSpace string
4344
webhookServerPort int
@@ -70,7 +71,7 @@ func main() {
7071
controller := app.NewController(kubeClient, fledgedClient, fledgedNameSpace,
7172
kubeInformerFactory.Core().V1().Nodes(),
7273
fledgedInformerFactory.Kubefledged().V1alpha2().ImageCaches(),
73-
imageCacheRefreshFrequency, imagePullDeadlineDuration, dockerClientImage, imagePullPolicy)
74+
imageCacheRefreshFrequency, imagePullDeadlineDuration, criClientImage, busyboxImage, imagePullPolicy)
7475

7576
glog.Info("Starting pre-flight checks")
7677
if err = controller.PreFlightChecks(); err != nil {
@@ -89,9 +90,14 @@ func main() {
8990
func init() {
9091
flag.DurationVar(&imagePullDeadlineDuration, "image-pull-deadline-duration", time.Minute*5, "Maximum duration allowed for pulling an image. After this duration, image pull is considered to have failed")
9192
flag.DurationVar(&imageCacheRefreshFrequency, "image-cache-refresh-frequency", time.Minute*15, "The image cache is refreshed periodically to ensure the cache is up to date. Setting this flag to 0s will disable refresh")
92-
flag.StringVar(&dockerClientImage, "cri-client-image", "senthilrch/kubefledged-cri-client:latest", "The image name of the cri client. the cri client is used when deleting images during purging the cache")
9393
flag.StringVar(&imagePullPolicy, "image-pull-policy", "IfNotPresent", "Image pull policy for pulling images into the cache. Possible values are 'IfNotPresent' and 'Always'. Default value is 'IfNotPresent'. Images with no or ':latest' tag are always pulled")
9494
if fledgedNameSpace = os.Getenv("KUBEFLEDGED_NAMESPACE"); fledgedNameSpace == "" {
9595
fledgedNameSpace = "kube-fledged"
9696
}
97+
if criClientImage = os.Getenv("KUBEFLEDGED_CRI_CLIENT_IMAGE"); criClientImage == "" {
98+
criClientImage = "senthilrch/kubefledged-cri-client:latest"
99+
}
100+
if busyboxImage = os.Getenv("BUSYBOX_IMAGE"); busyboxImage == "" {
101+
busyboxImage = "busybox:1.29.2"
102+
}
97103
}

0 commit comments

Comments
 (0)