-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add APIs for the HTTPBootConfig (#34)
- Loading branch information
Showing
13 changed files
with
372 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// HTTPBootConfigSpec defines the desired state of HTTPBootConfig | ||
type HTTPBootConfigSpec struct { | ||
SystemUUID string `json:"systemUUID,omitempty"` | ||
SystemIPs []string `json:"systemIP,omitempty"` // TODO: Add the custom serialization. For now validate at the controller. | ||
|
||
KernelURL string `json:"kernelURL,omitempty"` | ||
InitrdURL string `json:"initrdURL,omitempty"` | ||
SquashfsURL string `json:"squashfsURL,omitempty"` | ||
|
||
IgnitionSecretRef *corev1.LocalObjectReference `json:"ignitionSecretRef,omitempty"` | ||
|
||
CmdLine string `json:"cmdLine,omitempty"` | ||
} | ||
|
||
// HTTPBootConfigStatus defines the observed state of HTTPBootConfig | ||
type HTTPBootConfigStatus struct { | ||
State HTTPConfigState `json:"state,omitempty"` | ||
} | ||
|
||
type HTTPConfigState string | ||
|
||
const ( | ||
HTTPConfigStateReady HTTPConfigState = "Ready" | ||
HTTPConfigStatePending HTTPConfigState = "Pending" | ||
HTTPConfigStateError HTTPConfigState = "Error" | ||
) | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
|
||
// HTTPBootConfig is the Schema for the httpbootconfigs API | ||
type HTTPBootConfig struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec HTTPBootConfigSpec `json:"spec,omitempty"` | ||
Status HTTPBootConfigStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// HTTPBootConfigList contains a list of HTTPBootConfig | ||
type HTTPBootConfigList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []HTTPBootConfig `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&HTTPBootConfig{}, &HTTPBootConfigList{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# permissions for end users to edit httpbootconfigs. | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: clusterrole | ||
app.kubernetes.io/instance: httpbootconfig-editor-role | ||
app.kubernetes.io/component: rbac | ||
app.kubernetes.io/created-by: ipxe-operator | ||
app.kubernetes.io/part-of: ipxe-operator | ||
app.kubernetes.io/managed-by: kustomize | ||
name: httpbootconfig-editor-role | ||
rules: | ||
- apiGroups: | ||
- boot.ironcore.dev | ||
resources: | ||
- httpbootconfigs | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- boot.ironcore.dev | ||
resources: | ||
- httpbootconfigs/status | ||
verbs: | ||
- get |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# permissions for end users to view httpbootconfigs. | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: clusterrole | ||
app.kubernetes.io/instance: httpbootconfig-viewer-role | ||
app.kubernetes.io/component: rbac | ||
app.kubernetes.io/created-by: ipxe-operator | ||
app.kubernetes.io/part-of: ipxe-operator | ||
app.kubernetes.io/managed-by: kustomize | ||
name: httpbootconfig-viewer-role | ||
rules: | ||
- apiGroups: | ||
- boot.ironcore.dev | ||
resources: | ||
- httpbootconfigs | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- boot.ironcore.dev | ||
resources: | ||
- httpbootconfigs/status | ||
verbs: | ||
- get |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
apiVersion: boot.ironcore.dev/v1alpha1 | ||
kind: HTTPBootConfig | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: httpbootconfig | ||
app.kubernetes.io/instance: httpbootconfig-sample | ||
app.kubernetes.io/part-of: ipxe-operator | ||
app.kubernetes.io/managed-by: kustomize | ||
app.kubernetes.io/created-by: ipxe-operator | ||
name: httpbootconfig-sample | ||
spec: | ||
systemUUID: 1234 | ||
systemIPs: | ||
- 1.2.3.4 | ||
ignitionSecretRef: | ||
name: ignition-sample | ||
kernelURL: "10.0.0.1/ipxe/rootfs.vmlinuz" | ||
initrdURL: "10.0.0.1/ipxe/rootfs.initrd" | ||
squashfsURL: "10.0.0.1/ipxe/root.squashfs" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
## Append samples of your project ## | ||
resources: | ||
- boot_v1alpha1_ipxebootconfig.yaml | ||
- boot_v1alpha1_httpbootconfig.yaml | ||
#+kubebuilder:scaffold:manifestskustomizesamples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package controller | ||
|
||
import ( | ||
"context" | ||
|
||
"k8s.io/apimachinery/pkg/runtime" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/log" | ||
|
||
bootv1alpha1 "github.com/ironcore-dev/ipxe-operator/api/v1alpha1" | ||
) | ||
|
||
// HTTPBootConfigReconciler reconciles a HTTPBootConfig object | ||
type HTTPBootConfigReconciler struct { | ||
client.Client | ||
Scheme *runtime.Scheme | ||
} | ||
|
||
//+kubebuilder:rbac:groups=boot.ironcore.dev,resources=httpbootconfigs,verbs=get;list;watch;create;update;patch;delete | ||
//+kubebuilder:rbac:groups=boot.ironcore.dev,resources=httpbootconfigs/status,verbs=get;update;patch | ||
//+kubebuilder:rbac:groups=boot.ironcore.dev,resources=httpbootconfigs/finalizers,verbs=update | ||
|
||
// Reconcile is part of the main kubernetes reconciliation loop which aims to | ||
// move the current state of the cluster closer to the desired state. | ||
// TODO(user): Modify the Reconcile function to compare the state specified by | ||
// the HTTPBootConfig object against the actual cluster state, and then | ||
// perform operations to make the cluster state reflect the state specified by | ||
// the user. | ||
// | ||
// For more details, check Reconcile and its Result here: | ||
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
func (r *HTTPBootConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
_ = log.FromContext(ctx) | ||
|
||
// TODO(user): your logic here | ||
|
||
return ctrl.Result{}, nil | ||
} | ||
|
||
// SetupWithManager sets up the controller with the Manager. | ||
func (r *HTTPBootConfigReconciler) SetupWithManager(mgr ctrl.Manager) error { | ||
return ctrl.NewControllerManagedBy(mgr). | ||
For(&bootv1alpha1.HTTPBootConfig{}). | ||
Complete(r) | ||
} |
Oops, something went wrong.