Skip to content

Commit 1a1ac11

Browse files
authored
add distributionVersion field to controlplane (#77)
Signed-off-by: Riccardo Piccoli <[email protected]>
1 parent 3a62459 commit 1a1ac11

File tree

723 files changed

+110585
-13512
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

723 files changed

+110585
-13512
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM docker.io/library/golang:1.22 AS builder
2+
FROM docker.io/library/golang:1.23 AS builder
33
ARG TARGETOS
44
ARG TARGETARCH
55
ARG PROVIDER
@@ -17,6 +17,7 @@ COPY ${PROVIDER}/main.go ${PROVIDER}/main.go
1717
COPY bootstrap/api/ bootstrap/api/
1818
COPY controlplane/api/ controlplane/api/
1919
COPY util util
20+
COPY pkg pkg
2021
COPY assistedinstaller assistedinstaller
2122
COPY ${PROVIDER}/internal/ ${PROVIDER}/internal/
2223

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
209209
KUSTOMIZE_VERSION ?= v5.3.0
210210
CONTROLLER_TOOLS_VERSION ?= v0.14.0
211211
ENVTEST_VERSION ?= release-0.17
212-
GOLANGCI_LINT_VERSION ?= v1.54.2
212+
GOLANGCI_LINT_VERSION ?= v1.63.4
213213

214214
.PHONY: kustomize
215215
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.

PROJECT

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ resources:
3434
domain: cluster.x-k8s.io
3535
group: controlplane
3636
kind: OpenshiftAssistedControlPlane
37-
path: github.com/openshift-assisted/cluster-api-agent/api/controlplane/v1alpha1
38-
version: v1alpha1
37+
path: github.com/openshift-assisted/cluster-api-agent/api/controlplane/v1alpha2
38+
version: v1alpha2
3939
version: "3"

assistedinstaller/clusterdeployment.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package assistedinstaller
22

33
import (
4-
"github.com/openshift-assisted/cluster-api-agent/controlplane/api/v1alpha1"
4+
"github.com/openshift-assisted/cluster-api-agent/controlplane/api/v1alpha2"
55
"github.com/openshift-assisted/cluster-api-agent/util"
66
hivev1 "github.com/openshift/hive/apis/hive/v1"
77
"github.com/openshift/hive/apis/hive/v1/agent"
88
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
99
)
1010

1111
func GetClusterDeploymentFromConfig(
12-
acp *v1alpha1.OpenshiftAssistedControlPlane,
12+
acp *v1alpha2.OpenshiftAssistedControlPlane,
1313
clusterName string,
1414
) *hivev1.ClusterDeployment {
1515
assistedClusterName := clusterName

assistedinstaller/infraenv.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ func GetInfraEnvFromConfig(
5151
Proxy: config.Spec.Proxy,
5252
PullSecretRef: pullSecret,
5353
SSHAuthorizedKey: config.Spec.SSHAuthorizedKey,
54+
// Must be full-iso to ensure static networking settings is generated in the ignition
55+
ImageType: "full-iso",
5456
}
5557
return infraEnv
5658
}

bootstrap/internal/controller/agent_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (r *AgentReconciler) SetupWithManager(mgr ctrl.Manager) error {
4444
func (r *AgentReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
4545
log := ctrl.LoggerFrom(ctx)
4646
agent := &aiv1beta1.Agent{}
47-
if err := r.Get(ctx, req.NamespacedName, agent); err != nil {
47+
if err := r.Client.Get(ctx, req.NamespacedName, agent); err != nil {
4848
return ctrl.Result{}, client.IgnoreNotFound(err)
4949
}
5050

bootstrap/internal/controller/openshiftassistedconfig_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ func (r *OpenshiftAssistedConfigReconciler) ensureInfraEnv(ctx context.Context,
330330
_ = controllerutil.SetOwnerReference(config, infraEnv, r.Scheme)
331331
_ = controllerutil.SetOwnerReference(machine, infraEnv, r.Scheme)
332332

333-
err := r.Create(ctx, infraEnv)
333+
err := r.Client.Create(ctx, infraEnv)
334334
if err != nil && !apierrors.IsAlreadyExists(err) {
335335
log.V(logutil.DebugLevel).Error(err, "infra env error", "name", infraEnv.Name, "namespace", infraEnv.Namespace)
336336
// something went wrong, let's not exist because we might be able to read it and reference it in the status

bootstrap/internal/controller/suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package controller
1919
import (
2020
"testing"
2121

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

5757
utilruntime.Must(bootstrapv1alpha1.AddToScheme(testScheme))
58-
utilruntime.Must(controlplanev1alpha1.AddToScheme(testScheme))
58+
utilruntime.Must(controlplanev1alpha2.AddToScheme(testScheme))
5959
utilruntime.Must(corev1.AddToScheme(testScheme))
6060
utilruntime.Must(aiv1beta1.AddToScheme(testScheme))
6161
utilruntime.Must(hiveext.AddToScheme(testScheme))

bootstrap/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
"github.com/kelseyhightower/envconfig"
2828

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

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

@@ -68,7 +68,7 @@ func init() {
6868
utilruntime.Must(metal3.AddToScheme(scheme))
6969
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
7070
utilruntime.Must(bootstrapv1alpha1.AddToScheme(scheme))
71-
utilruntime.Must(controlplanev1alpha1.AddToScheme(scheme))
71+
utilruntime.Must(controlplanev1alpha2.AddToScheme(scheme))
7272
utilruntime.Must(aiv1beta1.AddToScheme(scheme))
7373
utilruntime.Must(hivev1.AddToScheme(scheme))
7474
utilruntime.Must(hiveext.AddToScheme(scheme))
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
package v1alpha1
1+
package v1alpha2
22

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

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

11-
// InfrastructureTemplateCloningFailedReason (Severity=Error) documents a OpenshiftControlplane failing to
11+
// InfrastructureTemplateCloningFailedReason (Severity=Error) documents a OpenshiftAssistedControlplane failing to
1212
// clone the infrastructure template.
1313
InfrastructureTemplateCloningFailedReason = "InfrastructureTemplateCloningFailed"
1414

15-
// BootstrapTemplateCloningFailedReason (Severity=Error) documents a OpenshiftControlplane failing to
15+
// BootstrapTemplateCloningFailedReason (Severity=Error) documents a OpenshiftAssistedControlplane failing to
1616
// clone the bootstrap template.
1717
BootstrapTemplateCloningFailedReason = "BootstrapTemplateCloningFailed"
1818

19-
// MachineGenerationFailedReason (Severity=Error) documents a OpenshiftControlplane failing to
19+
// MachineGenerationFailedReason (Severity=Error) documents a OpenshiftAssistedControlplane failing to
2020
// generate a machine object.
2121
MachineGenerationFailedReason = "MachineGenerationFailed"
2222
)

controlplane/api/v1alpha1/groupversion_info.go renamed to controlplane/api/v1alpha2/groupversion_info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

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

2222
import (
2323
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -26,7 +26,7 @@ import (
2626

2727
const (
2828
Group string = "controlplane.cluster.x-k8s.io"
29-
Version string = "v1alpha1"
29+
Version string = "v1alpha2"
3030
)
3131

3232
var (

controlplane/api/v1alpha1/openshiftassistedcontrolplane_types.go renamed to controlplane/api/v1alpha2/openshiftassistedcontrolplane_types.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package v1alpha1
17+
package v1alpha2
1818

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

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

128-
ReleaseImage string `json:"releaseImage"`
129-
130129
// ImageRegistryRef is a reference to a configmap containing both the additional
131130
// image registries and their corresponding certificate bundles to be used in the spoke cluster
132131
ImageRegistryRef *corev1.LocalObjectReference `json:"imageRegistryRef,omitempty"`
@@ -203,7 +202,7 @@ type OpenshiftAssistedControlPlaneStatus struct {
203202

204203
//+kubebuilder:object:root=true
205204
//+kubebuilder:subresource:status
206-
//+kubebuilder:resources:shortName=aocp
205+
//+kubebuilder:resources:shortName=oacp
207206
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector
208207
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels['cluster\\.x-k8s\\.io/cluster-name']",description="Cluster"
209208
// +kubebuilder:printcolumn:name="Initialized",type=boolean,JSONPath=".status.initialized",description="This denotes whether or not the control plane has the uploaded kubeadm-config configmap"
@@ -214,7 +213,7 @@ type OpenshiftAssistedControlPlaneStatus struct {
214213
// +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"
215214
// +kubebuilder:printcolumn:name="Unavailable",type=integer,JSONPath=".status.unavailableReplicas",description="Total number of unavailable machines targeted by this control plane"
216215
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of KubeadmControlPlane"
217-
// +kubebuilder:printcolumn:name="Version",type=string,JSONPath=".spec.version",description="OpenShift version associated with this control plane"
216+
// +kubebuilder:printcolumn:name="DistributionVersion",type=string,JSONPath=".spec.distributionVersion",description="OpenShift version associated with this control plane"
218217

219218
// OpenshiftAssistedControlPlane is the Schema for the openshiftassistedcontrolplane API
220219
type OpenshiftAssistedControlPlane struct {

controlplane/api/v1alpha1/zz_generated.deepcopy.go renamed to controlplane/api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_openshiftassistedcontrolplanes.yaml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ spec:
5656
name: Age
5757
type: date
5858
- description: OpenShift version associated with this control plane
59-
jsonPath: .spec.version
60-
name: Version
59+
jsonPath: .spec.distributionVersion
60+
name: DistributionVersion
6161
type: string
62-
name: v1alpha1
62+
name: v1alpha2
6363
schema:
6464
openAPIV3Schema:
6565
description: OpenshiftAssistedControlPlane is the Schema for the openshiftassistedcontrolplane
@@ -207,16 +207,17 @@ spec:
207207
type: string
208208
type: object
209209
x-kubernetes-map-type: atomic
210-
releaseImage:
211-
type: string
212210
sshAuthorizedKey:
213211
description: SSHAuthorizedKey ssh key for accessing the cluster
214212
nodes after reboot
215213
type: string
216214
required:
217215
- baseDomain
218-
- releaseImage
219216
type: object
217+
distributionVersion:
218+
description: DistributionVersion describes the targeted OpenShift
219+
version
220+
type: string
220221
machineTemplate:
221222
properties:
222223
infrastructureRef:
@@ -462,11 +463,9 @@ spec:
462463
replicas:
463464
format: int32
464465
type: integer
465-
version:
466-
type: string
467466
required:
467+
- distributionVersion
468468
- machineTemplate
469-
- version
470469
type: object
471470
status:
472471
description: OpenshiftAssistedControlPlaneStatus defines the observed

controlplane/config/crd/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ kind: Kustomization
1010
labels:
1111
- includeSelectors: true
1212
pairs:
13-
cluster.x-k8s.io/v1beta1: v1alpha1
13+
cluster.x-k8s.io/v1beta1: v1alpha2

controlplane/internal/auth/auth.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
66
)
77

8+
const PullsecretDataKey = ".dockerconfigjson"
9+
810
// Assisted-service expects the pull secret to
911
// 1. Have .dockerconfigjson as a key
1012
// 2. Have the value of .dockerconfigjson be a base64-encoded JSON
@@ -19,7 +21,7 @@ func GenerateFakePullSecret(name, namespace string) *corev1.Secret {
1921
Namespace: namespace,
2022
},
2123
Data: map[string][]byte{
22-
".dockerconfigjson": []byte(fakePullSecret),
24+
PullsecretDataKey: []byte(fakePullSecret),
2325
},
2426
}
2527
}

controlplane/internal/controller/agentclusterinstall_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"context"
2121
"fmt"
2222

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

65-
acp := controlplanev1alpha1.OpenshiftAssistedControlPlane{}
65+
acp := controlplanev1alpha2.OpenshiftAssistedControlPlane{}
6666
if err := util.GetTypedOwner(ctx, r.Client, aci, &acp); err != nil {
6767
return ctrl.Result{}, err
6868
}
@@ -86,7 +86,7 @@ func (r *AgentClusterInstallReconciler) Reconcile(ctx context.Context, req ctrl.
8686
func (r *AgentClusterInstallReconciler) reconcile(
8787
ctx context.Context,
8888
aci *hiveext.AgentClusterInstall,
89-
acp *controlplanev1alpha1.OpenshiftAssistedControlPlane,
89+
acp *controlplanev1alpha2.OpenshiftAssistedControlPlane,
9090
) error {
9191
if !hasKubeconfigRef(aci) {
9292
return nil
@@ -123,7 +123,7 @@ func (r *AgentClusterInstallReconciler) createKubeconfig(
123123
ctx context.Context,
124124
kubeconfigSecret *corev1.Secret,
125125
clusterName string,
126-
acp controlplanev1alpha1.OpenshiftAssistedControlPlane,
126+
acp controlplanev1alpha2.OpenshiftAssistedControlPlane,
127127
) error {
128128
kubeconfig, ok := kubeconfigSecret.Data["kubeconfig"]
129129
if !ok {
@@ -133,7 +133,7 @@ func (r *AgentClusterInstallReconciler) createKubeconfig(
133133
clusterNameKubeconfigSecret := GenerateSecretWithOwner(
134134
client.ObjectKey{Name: clusterName, Namespace: acp.Namespace},
135135
kubeconfig,
136-
*metav1.NewControllerRef(&acp, controlplanev1alpha1.GroupVersion.WithKind(openshiftAssistedControlPlaneKind)),
136+
*metav1.NewControllerRef(&acp, controlplanev1alpha2.GroupVersion.WithKind(openshiftAssistedControlPlaneKind)),
137137
)
138138
if err := r.Client.Create(ctx, clusterNameKubeconfigSecret); err != nil {
139139
if !apierrors.IsAlreadyExists(err) {
@@ -169,7 +169,7 @@ func (r *AgentClusterInstallReconciler) updateLabels(
169169
func (r *AgentClusterInstallReconciler) getACIKubeconfig(
170170
ctx context.Context,
171171
aci *hiveext.AgentClusterInstall,
172-
openshiftAssistedCP controlplanev1alpha1.OpenshiftAssistedControlPlane,
172+
openshiftAssistedCP controlplanev1alpha2.OpenshiftAssistedControlPlane,
173173
) (*corev1.Secret, error) {
174174
secretName := aci.Spec.ClusterMetadata.AdminKubeconfigSecretRef.Name
175175

0 commit comments

Comments
 (0)