Skip to content

Commit 21b8e5c

Browse files
yevgeny-shnaidmank8s-ci-robot
authored andcommitted
adding ModuleImagesConfig definition
ModuleImagesConfig CR will be used by the KMM operator to execute image existance flow via kubelet. The CR will hold the image to be verified in the spec, and the state of that image( exists/notexists) in the status field
1 parent dadd25e commit 21b8e5c

File tree

4 files changed

+321
-1
lines changed

4 files changed

+321
-1
lines changed

Dockerfile.kmm-operator-build

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22-alpine3.19 as builder
1+
FROM golang:1.23-alpine3.19 as builder
22

33
ENV GO111MODULE=on
44
ENV GOFLAGS=""
+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
Copyright 2025.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
type ImageState string
24+
25+
const (
26+
// ImageExists means that image exists in the specified repo
27+
ImageExists ImageState = "Exists"
28+
// ImageNotExists means that image does not exist in the specified repo
29+
ImageDoesNotExist ImageState = "DoesNotExist"
30+
)
31+
32+
// ModuleImageSpec describes the image whose state needs to be queried
33+
type ModuleImageSpec struct {
34+
// image
35+
Image string `json:"image"`
36+
// generation counter of the image config
37+
Generation int `json:"generation"`
38+
}
39+
40+
// ModuleImagesConfigSpec describes the images of the Module whose status needs to be verified
41+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
42+
// +kubebuilder:validation:Required
43+
type ModuleImagesConfigSpec struct {
44+
Images []ModuleImageSpec `json:"images"`
45+
}
46+
47+
type ModuleImageState struct {
48+
// image
49+
Image string `json:"image"`
50+
// status of the image
51+
// one of: Exists, notExists
52+
Status ImageState `json:"status"`
53+
// observedGeneration counter is updated on each status update
54+
ObservedGeneration int `json:"observedGeneration"`
55+
}
56+
57+
// ModuleImagesConfigStatus describes the status of the images that need to be verified (defined in the spec)
58+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
59+
// +kubebuilder:validation:Required
60+
type ModuleImagesConfigStatus struct {
61+
ImagesStates []ModuleImageState `json:"imagesStates"`
62+
}
63+
64+
// +kubebuilder:object:root=true
65+
// +kubebuilder:subresource:status
66+
67+
// ModuleImagesConfig keeps the request for images' state for a KMM Module.
68+
// +kubebuilder:resource:path=moduleimagesconfigs,scope=Namespaced,shortName=mic
69+
// +operator-sdk:csv:customresourcedefinitions:displayName="Module Images Config"
70+
type ModuleImagesConfig struct {
71+
metav1.TypeMeta `json:",inline"`
72+
metav1.ObjectMeta `json:"metadata,omitempty"`
73+
74+
Spec ModuleImagesConfigSpec `json:"spec,omitempty"`
75+
Status ModuleImagesConfigStatus `json:"status,omitempty"`
76+
}
77+
78+
// +kubebuilder:object:root=true
79+
80+
// ModuleImagesConfigList is a list of ModuleImagesConfig objects.
81+
type ModuleImagesConfigList struct {
82+
metav1.TypeMeta `json:",inline"`
83+
metav1.ListMeta `json:"metadata,omitempty"`
84+
85+
// List of ModuleImagesConfig. More info:
86+
// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md
87+
Items []ModuleImagesConfig `json:"items"`
88+
}
89+
90+
func init() {
91+
SchemeBuilder.Register(&ModuleImagesConfig{}, &ModuleImagesConfigList{})
92+
}

api/v1beta1/zz_generated.deepcopy.go

+129
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.16.1
7+
name: moduleimagesconfigs.kmm.sigs.x-k8s.io
8+
spec:
9+
group: kmm.sigs.x-k8s.io
10+
names:
11+
kind: ModuleImagesConfig
12+
listKind: ModuleImagesConfigList
13+
plural: moduleimagesconfigs
14+
shortNames:
15+
- mic
16+
singular: moduleimagesconfig
17+
scope: Namespaced
18+
versions:
19+
- name: v1beta1
20+
schema:
21+
openAPIV3Schema:
22+
description: ModuleImagesConfig keeps the request for images' state for a
23+
KMM Module.
24+
properties:
25+
apiVersion:
26+
description: |-
27+
APIVersion defines the versioned schema of this representation of an object.
28+
Servers should convert recognized schemas to the latest internal value, and
29+
may reject unrecognized values.
30+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
31+
type: string
32+
kind:
33+
description: |-
34+
Kind is a string value representing the REST resource this object represents.
35+
Servers may infer this from the endpoint the client submits requests to.
36+
Cannot be updated.
37+
In CamelCase.
38+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
39+
type: string
40+
metadata:
41+
type: object
42+
spec:
43+
description: |-
44+
ModuleImagesConfigSpec describes the images of the Module whose status needs to be verified
45+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
46+
properties:
47+
images:
48+
items:
49+
description: ModuleImageSpec describes the image whose state needs
50+
to be queried
51+
properties:
52+
generation:
53+
description: generation counter of the image config
54+
type: integer
55+
image:
56+
description: image
57+
type: string
58+
required:
59+
- generation
60+
- image
61+
type: object
62+
type: array
63+
required:
64+
- images
65+
type: object
66+
status:
67+
description: |-
68+
ModuleImagesConfigStatus describes the status of the images that need to be verified (defined in the spec)
69+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
70+
properties:
71+
imagesStates:
72+
items:
73+
properties:
74+
image:
75+
description: image
76+
type: string
77+
observedGeneration:
78+
description: observedGeneration counter is updated on each status
79+
update
80+
type: integer
81+
status:
82+
description: |-
83+
status of the image
84+
one of: Exists, notExists
85+
type: string
86+
required:
87+
- image
88+
- observedGeneration
89+
- status
90+
type: object
91+
type: array
92+
required:
93+
- imagesStates
94+
type: object
95+
type: object
96+
served: true
97+
storage: true
98+
subresources:
99+
status: {}

0 commit comments

Comments
 (0)