Skip to content

Commit

Permalink
Merge pull request #87 from srl-labs/feat/image-pull-cr
Browse files Browse the repository at this point in the history
feat: ImageRequest cr instead of http request
  • Loading branch information
carlmontanari authored Dec 17, 2023
2 parents 2e09b75 + 7d1ccda commit 691d8c0
Show file tree
Hide file tree
Showing 43 changed files with 2,356 additions and 501 deletions.
4 changes: 2 additions & 2 deletions apis/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ const (
// TopologyKindKne is the "kne" kind of topology.
TopologyKindKne = "kne"

// TopologyKindUnknown is the kind of topology for unknown topologies.
TopologyKindUnknown = "unknown"
// ImageRequest is the Kind of the ImageRequest custom resource.
ImageRequest = "imageRequest"
)
58 changes: 58 additions & 0 deletions apis/v1alpha1/imagerequest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package v1alpha1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ImageRequest is an object that represents a request (from a launcher pod) to pull an image on a
// given kubernetes node such that the image can be "pulled through" into the launcher docker
// daemon.
// +k8s:openapi-gen=true
type ImageRequest struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ImageRequestSpec `json:"spec,omitempty"`
Status ImageRequestStatus `json:"status,omitempty"`
}

// ImageRequestSpec is the spec for a Config resource.
type ImageRequestSpec struct {
// TopologyName is the name of the topology requesting the image.
TopologyName string `json:"topologyName"`
// TopologyNodeName is the name of the node in the topology (i.e. the router name in a
// containerlab topology) that the image is being requested for.
TopologyNodeName string `json:"topologyNodeName"`
// KubernetesNode is the node where the launcher pod is running and where the image should be
// pulled too.
KubernetesNode string `json:"kubernetesNode"`
// RequestedImage is the image that the launcher pod wants the controller to get pulled onto
// the specified node.
RequestedImage string `json:"requestedImage"`
// RequestedImagePullSecrets is a list of configured pull secrets to set in the pull pod spec.
// +listType=set
// +optional
RequestedImagePullSecrets []string `json:"requestedImagePullSecrets"`
}

// ImageRequestStatus is the status for a ImageRequest resource.
type ImageRequestStatus struct {
// Accepted indicates that the ImageRequest controller has seen this image request and is going
// to process it. This can be useful to let the requesting pod know that "yep, this is in the
// works, and i can go watch the cri images on this node now".
Accepted bool `json:"accepted"`
// Complete indicates that the ImageRequest controller has seen that the puller pod has done its
// job and that the image has been pulled onto the requested node.
Complete bool `json:"complete"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ImageRequestList is a list of ImageRequest objects.
type ImageRequestList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`

Items []ImageRequest `json:"items"`
}
2 changes: 2 additions & 0 deletions apis/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func GetAPIs() (apimachineryscheme.GroupVersion, []apimachineryruntime.Object) {
return SchemeGroupVersion, []apimachineryruntime.Object{
&Config{},
&ConfigList{},
&ImageRequest{},
&ImageRequestList{},
&Topology{},
&TopologyList{},
}
Expand Down
98 changes: 98 additions & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 89 additions & 0 deletions assets/crd/clabernetes.containerlab.dev_imagerequests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
name: imagerequests.clabernetes.containerlab.dev
spec:
group: clabernetes.containerlab.dev
names:
kind: ImageRequest
listKind: ImageRequestList
plural: imagerequests
singular: imagerequest
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: ImageRequest is an object that represents a request (from a launcher
pod) to pull an image on a given kubernetes node such that the image can
be "pulled through" into the launcher docker daemon.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ImageRequestSpec is the spec for a Config resource.
properties:
kubernetesNode:
description: KubernetesNode is the node where the launcher pod is
running and where the image should be pulled too.
type: string
requestedImage:
description: RequestedImage is the image that the launcher pod wants
the controller to get pulled onto the specified node.
type: string
requestedImagePullSecrets:
description: RequestedImagePullSecrets is a list of configured pull
secrets to set in the pull pod spec.
items:
type: string
type: array
x-kubernetes-list-type: set
topologyName:
description: TopologyName is the name of the topology requesting the
image.
type: string
topologyNodeName:
description: TopologyNodeName is the name of the node in the topology
(i.e. the router name in a containerlab topology) that the image
is being requested for.
type: string
required:
- kubernetesNode
- requestedImage
- topologyName
- topologyNodeName
type: object
status:
description: ImageRequestStatus is the status for a ImageRequest resource.
properties:
accepted:
description: Accepted indicates that the ImageRequest controller has
seen this image request and is going to process it. This can be
useful to let the requesting pod know that "yep, this is in the
works, and i can go watch the cri images on this node now".
type: boolean
complete:
description: Complete indicates that the ImageRequest controller has
seen that the puller pod has done its job and that the image has
been pulled onto the requested node.
type: boolean
required:
- accepted
- complete
type: object
type: object
served: true
storage: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
name: imagerequests.clabernetes.containerlab.dev
spec:
group: clabernetes.containerlab.dev
names:
kind: ImageRequest
listKind: ImageRequestList
plural: imagerequests
singular: imagerequest
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: ImageRequest is an object that represents a request (from a launcher
pod) to pull an image on a given kubernetes node such that the image can
be "pulled through" into the launcher docker daemon.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ImageRequestSpec is the spec for a Config resource.
properties:
kubernetesNode:
description: KubernetesNode is the node where the launcher pod is
running and where the image should be pulled too.
type: string
requestedImage:
description: RequestedImage is the image that the launcher pod wants
the controller to get pulled onto the specified node.
type: string
requestedImagePullSecrets:
description: RequestedImagePullSecrets is a list of configured pull
secrets to set in the pull pod spec.
items:
type: string
type: array
x-kubernetes-list-type: set
topologyName:
description: TopologyName is the name of the topology requesting the
image.
type: string
topologyNodeName:
description: TopologyNodeName is the name of the node in the topology
(i.e. the router name in a containerlab topology) that the image
is being requested for.
type: string
required:
- kubernetesNode
- requestedImage
- topologyName
- topologyNodeName
type: object
status:
description: ImageRequestStatus is the status for a ImageRequest resource.
properties:
accepted:
description: Accepted indicates that the ImageRequest controller has
seen this image request and is going to process it. This can be
useful to let the requesting pod know that "yep, this is in the
works, and i can go watch the cri images on this node now".
type: boolean
complete:
description: Complete indicates that the ImageRequest controller has
seen that the puller pod has done its job and that the image has
been pulled onto the requested node.
type: boolean
required:
- accepted
- complete
type: object
type: object
served: true
storage: true
Loading

0 comments on commit 691d8c0

Please sign in to comment.