Skip to content

add distributionVersion field to controlplane #77

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

Merged
merged 1 commit into from
Feb 13, 2025
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM docker.io/library/golang:1.22 AS builder
FROM docker.io/library/golang:1.23 AS builder
ARG TARGETOS
ARG TARGETARCH
ARG PROVIDER
Expand All @@ -17,6 +17,7 @@ COPY ${PROVIDER}/main.go ${PROVIDER}/main.go
COPY bootstrap/api/ bootstrap/api/
COPY controlplane/api/ controlplane/api/
COPY util util
COPY pkg pkg
COPY assistedinstaller assistedinstaller
COPY ${PROVIDER}/internal/ ${PROVIDER}/internal/

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
KUSTOMIZE_VERSION ?= v5.3.0
CONTROLLER_TOOLS_VERSION ?= v0.14.0
ENVTEST_VERSION ?= release-0.17
GOLANGCI_LINT_VERSION ?= v1.54.2
GOLANGCI_LINT_VERSION ?= v1.63.4

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
4 changes: 2 additions & 2 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ resources:
domain: cluster.x-k8s.io
group: controlplane
kind: OpenshiftAssistedControlPlane
path: github.com/openshift-assisted/cluster-api-agent/api/controlplane/v1alpha1
version: v1alpha1
path: github.com/openshift-assisted/cluster-api-agent/api/controlplane/v1alpha2
version: v1alpha2
version: "3"
4 changes: 2 additions & 2 deletions assistedinstaller/clusterdeployment.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package assistedinstaller

import (
"github.com/openshift-assisted/cluster-api-agent/controlplane/api/v1alpha1"
"github.com/openshift-assisted/cluster-api-agent/controlplane/api/v1alpha2"
"github.com/openshift-assisted/cluster-api-agent/util"
hivev1 "github.com/openshift/hive/apis/hive/v1"
"github.com/openshift/hive/apis/hive/v1/agent"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func GetClusterDeploymentFromConfig(
acp *v1alpha1.OpenshiftAssistedControlPlane,
acp *v1alpha2.OpenshiftAssistedControlPlane,
clusterName string,
) *hivev1.ClusterDeployment {
assistedClusterName := clusterName
Expand Down
2 changes: 2 additions & 0 deletions assistedinstaller/infraenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func GetInfraEnvFromConfig(
Proxy: config.Spec.Proxy,
PullSecretRef: pullSecret,
SSHAuthorizedKey: config.Spec.SSHAuthorizedKey,
// Must be full-iso to ensure static networking settings is generated in the ignition
ImageType: "full-iso",
}
return infraEnv
}
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/internal/controller/agent_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (r *AgentReconciler) SetupWithManager(mgr ctrl.Manager) error {
func (r *AgentReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := ctrl.LoggerFrom(ctx)
agent := &aiv1beta1.Agent{}
if err := r.Get(ctx, req.NamespacedName, agent); err != nil {
if err := r.Client.Get(ctx, req.NamespacedName, agent); err != nil {
return ctrl.Result{}, client.IgnoreNotFound(err)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func (r *OpenshiftAssistedConfigReconciler) ensureInfraEnv(ctx context.Context,
_ = controllerutil.SetOwnerReference(config, infraEnv, r.Scheme)
_ = controllerutil.SetOwnerReference(machine, infraEnv, r.Scheme)

err := r.Create(ctx, infraEnv)
err := r.Client.Create(ctx, infraEnv)
if err != nil && !apierrors.IsAlreadyExists(err) {
log.V(logutil.DebugLevel).Error(err, "infra env error", "name", infraEnv.Name, "namespace", infraEnv.Namespace)
// something went wrong, let's not exist because we might be able to read it and reference it in the status
Expand Down
4 changes: 2 additions & 2 deletions bootstrap/internal/controller/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package controller
import (
"testing"

controlplanev1alpha1 "github.com/openshift-assisted/cluster-api-agent/controlplane/api/v1alpha1"
controlplanev1alpha2 "github.com/openshift-assisted/cluster-api-agent/controlplane/api/v1alpha2"
hiveext "github.com/openshift/assisted-service/api/hiveextension/v1beta1"
aiv1beta1 "github.com/openshift/assisted-service/api/v1beta1"
hivev1 "github.com/openshift/hive/apis/hive/v1"
Expand Down Expand Up @@ -55,7 +55,7 @@ var _ = BeforeSuite(func() {
By("bootstrapping test environment")

utilruntime.Must(bootstrapv1alpha1.AddToScheme(testScheme))
utilruntime.Must(controlplanev1alpha1.AddToScheme(testScheme))
utilruntime.Must(controlplanev1alpha2.AddToScheme(testScheme))
utilruntime.Must(corev1.AddToScheme(testScheme))
utilruntime.Must(aiv1beta1.AddToScheme(testScheme))
utilruntime.Must(hiveext.AddToScheme(testScheme))
Expand Down
4 changes: 2 additions & 2 deletions bootstrap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

"github.com/kelseyhightower/envconfig"

controlplanev1alpha1 "github.com/openshift-assisted/cluster-api-agent/controlplane/api/v1alpha1"
controlplanev1alpha2 "github.com/openshift-assisted/cluster-api-agent/controlplane/api/v1alpha2"

hivev1 "github.com/openshift/hive/apis/hive/v1"

Expand Down Expand Up @@ -68,7 +68,7 @@ func init() {
utilruntime.Must(metal3.AddToScheme(scheme))
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(bootstrapv1alpha1.AddToScheme(scheme))
utilruntime.Must(controlplanev1alpha1.AddToScheme(scheme))
utilruntime.Must(controlplanev1alpha2.AddToScheme(scheme))
utilruntime.Must(aiv1beta1.AddToScheme(scheme))
utilruntime.Must(hivev1.AddToScheme(scheme))
utilruntime.Must(hiveext.AddToScheme(scheme))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package v1alpha1
package v1alpha2

import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"

const (
// MachinesCreatedCondition documents that the machines controlled by the OpenshiftControlplane are created.
// MachinesCreatedCondition documents that the machines controlled by the OpenshiftAssistedControlplane are created.
// When this condition is false, it indicates that there was an error when cloning the infrastructure/bootstrap template or
// when generating the machine object.
MachinesCreatedCondition clusterv1.ConditionType = "MachinesCreated"

// InfrastructureTemplateCloningFailedReason (Severity=Error) documents a OpenshiftControlplane failing to
// InfrastructureTemplateCloningFailedReason (Severity=Error) documents a OpenshiftAssistedControlplane failing to
// clone the infrastructure template.
InfrastructureTemplateCloningFailedReason = "InfrastructureTemplateCloningFailed"

// BootstrapTemplateCloningFailedReason (Severity=Error) documents a OpenshiftControlplane failing to
// BootstrapTemplateCloningFailedReason (Severity=Error) documents a OpenshiftAssistedControlplane failing to
// clone the bootstrap template.
BootstrapTemplateCloningFailedReason = "BootstrapTemplateCloningFailed"

// MachineGenerationFailedReason (Severity=Error) documents a OpenshiftControlplane failing to
// MachineGenerationFailedReason (Severity=Error) documents a OpenshiftAssistedControlplane failing to
// generate a machine object.
MachineGenerationFailedReason = "MachineGenerationFailed"
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1beta1 contains API Schema definitions for the controlplane v1beta1 API group
// Package v1alpha2 contains API Schema definitions for the controlplane v1alpha2 API group
// +kubebuilder:object:generate=true
// +groupName=controlplane.cluster.x-k8s.io
package v1alpha1
package v1alpha2

import (
"k8s.io/apimachinery/pkg/runtime/schema"
Expand All @@ -26,7 +26,7 @@ import (

const (
Group string = "controlplane.cluster.x-k8s.io"
Version string = "v1alpha1"
Version string = "v1alpha2"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1
package v1alpha2

import (
bootstrapv1beta1 "github.com/openshift-assisted/cluster-api-agent/bootstrap/api/v1alpha1"
Expand Down Expand Up @@ -65,7 +65,8 @@ type OpenshiftAssistedControlPlaneSpec struct {
MachineTemplate OpenshiftAssistedControlPlaneMachineTemplate `json:"machineTemplate"`
OpenshiftAssistedConfigSpec bootstrapv1beta1.OpenshiftAssistedConfigSpec `json:"openshiftAssistedConfigSpec,omitempty"`
Replicas int32 `json:"replicas,omitempty"`
Version string `json:"version"`
// DistributionVersion describes the targeted OpenShift version
DistributionVersion string `json:"distributionVersion"`
}

// OpenshiftAssistedControlPlaneConfigSpec defines configuration for the agent-provisioned cluster
Expand Down Expand Up @@ -125,8 +126,6 @@ type OpenshiftAssistedControlPlaneConfigSpec struct {
// PullSecretRef references pull secret necessary for the cluster installation
PullSecretRef *corev1.LocalObjectReference `json:"pullSecretRef,omitempty"`

ReleaseImage string `json:"releaseImage"`

// ImageRegistryRef is a reference to a configmap containing both the additional
// image registries and their corresponding certificate bundles to be used in the spoke cluster
ImageRegistryRef *corev1.LocalObjectReference `json:"imageRegistryRef,omitempty"`
Expand Down Expand Up @@ -203,7 +202,7 @@ type OpenshiftAssistedControlPlaneStatus struct {

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resources:shortName=aocp
//+kubebuilder:resources:shortName=oacp
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels['cluster\\.x-k8s\\.io/cluster-name']",description="Cluster"
// +kubebuilder:printcolumn:name="Initialized",type=boolean,JSONPath=".status.initialized",description="This denotes whether or not the control plane has the uploaded kubeadm-config configmap"
Expand All @@ -214,7 +213,7 @@ type OpenshiftAssistedControlPlaneStatus struct {
// +kubebuilder:printcolumn:name="Updated",type=integer,JSONPath=".status.updatedReplicas",description="Total number of non-terminated machines targeted by this control plane that have the desired template spec"
// +kubebuilder:printcolumn:name="Unavailable",type=integer,JSONPath=".status.unavailableReplicas",description="Total number of unavailable machines targeted by this control plane"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of KubeadmControlPlane"
// +kubebuilder:printcolumn:name="Version",type=string,JSONPath=".spec.version",description="OpenShift version associated with this control plane"
// +kubebuilder:printcolumn:name="DistributionVersion",type=string,JSONPath=".spec.distributionVersion",description="OpenShift version associated with this control plane"

// OpenshiftAssistedControlPlane is the Schema for the openshiftassistedcontrolplane API
type OpenshiftAssistedControlPlane struct {
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ spec:
name: Age
type: date
- description: OpenShift version associated with this control plane
jsonPath: .spec.version
name: Version
jsonPath: .spec.distributionVersion
name: DistributionVersion
type: string
name: v1alpha1
name: v1alpha2
schema:
openAPIV3Schema:
description: OpenshiftAssistedControlPlane is the Schema for the openshiftassistedcontrolplane
Expand Down Expand Up @@ -207,16 +207,17 @@ spec:
type: string
type: object
x-kubernetes-map-type: atomic
releaseImage:
type: string
sshAuthorizedKey:
description: SSHAuthorizedKey ssh key for accessing the cluster
nodes after reboot
type: string
required:
- baseDomain
- releaseImage
type: object
distributionVersion:
description: DistributionVersion describes the targeted OpenShift
version
type: string
machineTemplate:
properties:
infrastructureRef:
Expand Down Expand Up @@ -462,11 +463,9 @@ spec:
replicas:
format: int32
type: integer
version:
type: string
required:
- distributionVersion
- machineTemplate
- version
type: object
status:
description: OpenshiftAssistedControlPlaneStatus defines the observed
Expand Down
2 changes: 1 addition & 1 deletion controlplane/config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ kind: Kustomization
labels:
- includeSelectors: true
pairs:
cluster.x-k8s.io/v1beta1: v1alpha1
cluster.x-k8s.io/v1beta1: v1alpha2
4 changes: 3 additions & 1 deletion controlplane/internal/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const PullsecretDataKey = ".dockerconfigjson"

// Assisted-service expects the pull secret to
// 1. Have .dockerconfigjson as a key
// 2. Have the value of .dockerconfigjson be a base64-encoded JSON
Expand All @@ -19,7 +21,7 @@ func GenerateFakePullSecret(name, namespace string) *corev1.Secret {
Namespace: namespace,
},
Data: map[string][]byte{
".dockerconfigjson": []byte(fakePullSecret),
PullsecretDataKey: []byte(fakePullSecret),
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"context"
"fmt"

controlplanev1alpha1 "github.com/openshift-assisted/cluster-api-agent/controlplane/api/v1alpha1"
controlplanev1alpha2 "github.com/openshift-assisted/cluster-api-agent/controlplane/api/v1alpha2"
"github.com/openshift-assisted/cluster-api-agent/util"
logutil "github.com/openshift-assisted/cluster-api-agent/util/log"
hiveext "github.com/openshift/assisted-service/api/hiveextension/v1beta1"
Expand Down Expand Up @@ -62,7 +62,7 @@ func (r *AgentClusterInstallReconciler) Reconcile(ctx context.Context, req ctrl.
}
log.WithValues("agent_cluster_install", aci.Name, "agent_cluster_install_namespace", aci.Namespace)

acp := controlplanev1alpha1.OpenshiftAssistedControlPlane{}
acp := controlplanev1alpha2.OpenshiftAssistedControlPlane{}
if err := util.GetTypedOwner(ctx, r.Client, aci, &acp); err != nil {
return ctrl.Result{}, err
}
Expand All @@ -86,7 +86,7 @@ func (r *AgentClusterInstallReconciler) Reconcile(ctx context.Context, req ctrl.
func (r *AgentClusterInstallReconciler) reconcile(
ctx context.Context,
aci *hiveext.AgentClusterInstall,
acp *controlplanev1alpha1.OpenshiftAssistedControlPlane,
acp *controlplanev1alpha2.OpenshiftAssistedControlPlane,
) error {
if !hasKubeconfigRef(aci) {
return nil
Expand Down Expand Up @@ -123,7 +123,7 @@ func (r *AgentClusterInstallReconciler) createKubeconfig(
ctx context.Context,
kubeconfigSecret *corev1.Secret,
clusterName string,
acp controlplanev1alpha1.OpenshiftAssistedControlPlane,
acp controlplanev1alpha2.OpenshiftAssistedControlPlane,
) error {
kubeconfig, ok := kubeconfigSecret.Data["kubeconfig"]
if !ok {
Expand All @@ -133,7 +133,7 @@ func (r *AgentClusterInstallReconciler) createKubeconfig(
clusterNameKubeconfigSecret := GenerateSecretWithOwner(
client.ObjectKey{Name: clusterName, Namespace: acp.Namespace},
kubeconfig,
*metav1.NewControllerRef(&acp, controlplanev1alpha1.GroupVersion.WithKind(openshiftAssistedControlPlaneKind)),
*metav1.NewControllerRef(&acp, controlplanev1alpha2.GroupVersion.WithKind(openshiftAssistedControlPlaneKind)),
)
if err := r.Client.Create(ctx, clusterNameKubeconfigSecret); err != nil {
if !apierrors.IsAlreadyExists(err) {
Expand Down Expand Up @@ -169,7 +169,7 @@ func (r *AgentClusterInstallReconciler) updateLabels(
func (r *AgentClusterInstallReconciler) getACIKubeconfig(
ctx context.Context,
aci *hiveext.AgentClusterInstall,
openshiftAssistedCP controlplanev1alpha1.OpenshiftAssistedControlPlane,
openshiftAssistedCP controlplanev1alpha2.OpenshiftAssistedControlPlane,
) (*corev1.Secret, error) {
secretName := aci.Spec.ClusterMetadata.AdminKubeconfigSecretRef.Name

Expand Down
Loading