Skip to content

Commit

Permalink
Merge branch 'main' into extend-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gfariasalves-ionos authored May 7, 2024
2 parents e81bda7 + 1b58f35 commit 83805dd
Show file tree
Hide file tree
Showing 38 changed files with 587 additions and 248 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ jobs:
- name: Run lint
run: "make lint"

# TODO(lubedacht) include later
# yamllint:
# name: yamllint
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: ibiqlik/action-yamllint@v3
# with:
# format: github
yamllint:
name: yamllint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ibiqlik/action-yamllint@v3
with:
format: github

actionlint:
name: actionlint
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,3 @@ jobs:
go-version-file: go.mod
- name: Run tests
run: "make test"

# TODO(lubedacht) include later
# - name: SonarCloud Scan
# uses: SonarSource/[email protected]
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
34 changes: 34 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
extends: default

rules:
# the default of 80 is overly-restrictive, particularly when nested
line-length:
max: 120
level: warning
# as this repository also contains generated yaml, we only enforce
# indentation consistency within a file
indentation:
spaces: consistent
indent-sequences: consistent
level: warning
comments:
min-spaces-from-content: 1
# comments-indentation linting has unwanted edgecases:
# https://github.com/adrienverge/yamllint/issues/141
comments-indentation: disable

ignore:
# generated files
- config/crd
- config/certmanager
- config/prometheus
- config/rbac
- test/e2e
- out
- .*.yaml
- .*.yml
# these are clusterctl templates, not yaml
- templates
# github actions checked by actionlint
- .github/workflows
4 changes: 4 additions & 0 deletions api/v1alpha1/ionoscloudcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const (
// associated with the IonosCloudCluster before removing it from the API server.
ClusterFinalizer = "ionoscloudcluster.infrastructure.cluster.x-k8s.io"

// ClusterCredentialsFinalizer allows cleanup of resources, which are
// associated with the IonosCloudCluster credentials before removing it from the API server.
ClusterCredentialsFinalizer = ClusterFinalizer + "/credentials"

// IonosCloudClusterReady is the condition for the IonosCloudCluster, which indicates that the cluster is ready.
IonosCloudClusterReady clusterv1.ConditionType = "ClusterReady"

Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/ionoscloudcluster_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ var _ = Describe("IonosCloudCluster", func() {
It("should allow creating valid clusters", func() {
Expect(k8sClient.Create(context.Background(), defaultCluster())).To(Succeed())
})
It("should work with a FQDN controlplane endpoint", func() {
cluster := defaultCluster()
cluster.Spec.ControlPlaneEndpoint.Host = "example.org"
Expect(k8sClient.Create(context.Background(), cluster)).To(Succeed())
})
It("should not allow creating clusters with empty credential secret", func() {
cluster := defaultCluster()
cluster.Spec.CredentialsRef.Name = ""
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/ionoscloudmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ type IonosCloudMachineSpec struct {
//
// If the machine is a control plane machine, this field will not be taken into account.
//+kubebuilder:validation:XValidation:rule="self == oldSelf",message="failoverIP is immutable"
//+kubebuilder:validation:XValidation:rule=`self == "" || self == "AUTO" || self.matches("((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$")`,message="failoverIP must be either 'AUTO' or a valid IPv4 address"
//+kubebuilder:validation:XValidation:rule=`self == "AUTO" || self.matches("((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$")`,message="failoverIP must be either 'AUTO' or a valid IPv4 address"
//+optional
FailoverIP string `json:"failoverIP"`
FailoverIP *string `json:"failoverIP,omitempty"`
}

// Networks contains a list of additional LAN IDs
Expand Down
24 changes: 12 additions & 12 deletions api/v1alpha1/ionoscloudmachine_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,24 +342,24 @@ var _ = Describe("IonosCloudMachine Tests", func() {
Context("FailoverIP", func() {
It("should allow setting AUTO as the value", func() {
m := defaultMachine()
m.Spec.FailoverIP = CloudResourceConfigAuto
m.Spec.FailoverIP = ptr.To(CloudResourceConfigAuto)
Expect(k8sClient.Create(context.Background(), m)).To(Succeed())
Expect(m.Spec.FailoverIP).To(Equal(CloudResourceConfigAuto))
Expect(m.Spec.FailoverIP).To(Equal(ptr.To(CloudResourceConfigAuto)))
})
It("should allow setting a valid IPv4 address", func() {
m := defaultMachine()
m.Spec.FailoverIP = "203.0.113.1"
m.Spec.FailoverIP = ptr.To("203.0.113.1")
Expect(k8sClient.Create(context.Background(), m)).To(Succeed())
Expect(m.Spec.FailoverIP).To(Equal("203.0.113.1"))
Expect(m.Spec.FailoverIP).To(Equal(ptr.To("203.0.113.1")))
})
It("should allow setting empty string", func() {
It("should allow setting null", func() {
m := defaultMachine()
Expect(k8sClient.Create(context.Background(), m)).To(Succeed())
Expect(m.Spec.FailoverIP).To(Equal(""))
Expect(m.Spec.FailoverIP).To(BeNil())
})
DescribeTable("should not allow setting invalid IPv4 addresses", func(ip string) {
m := defaultMachine()
m.Spec.FailoverIP = ip
m.Spec.FailoverIP = &ip
Expect(k8sClient.Create(context.Background(), m)).ToNot(Succeed())
},
Entry("IPv4 out of range", "203.0.113.256"),
Expand All @@ -370,17 +370,17 @@ var _ = Describe("IonosCloudMachine Tests", func() {
)
It("should require AUTO to be in capital letters", func() {
m := defaultMachine()
m.Spec.FailoverIP = "Auto"
m.Spec.FailoverIP = ptr.To("Auto")
Expect(k8sClient.Create(context.Background(), m)).ToNot(Succeed())
})
It("should be immutable", func() {
m := defaultMachine()
m.Spec.FailoverIP = "AUTO"
m.Spec.FailoverIP = ptr.To(CloudResourceConfigAuto)
Expect(k8sClient.Create(context.Background(), m)).To(Succeed())
Expect(m.Spec.FailoverIP).To(Equal("AUTO"))
m.Spec.FailoverIP = "127.0.0.1"
Expect(m.Spec.FailoverIP).To(Equal(ptr.To(CloudResourceConfigAuto)))
m.Spec.FailoverIP = ptr.To("127.0.0.1")
Expect(k8sClient.Update(context.Background(), m)).ToNot(Succeed())
m.Spec.FailoverIP = ""
m.Spec.FailoverIP = ptr.To("")
Expect(k8sClient.Update(context.Background(), m)).ToNot(Succeed())
})
})
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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 @@ -158,7 +158,7 @@ spec:
- message: failoverIP is immutable
rule: self == oldSelf
- message: failoverIP must be either 'AUTO' or a valid IPv4 address
rule: self == "" || self == "AUTO" || self.matches("((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$")
rule: self == "AUTO" || self.matches("((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$")
memoryMB:
default: 3072
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ spec:
rule: self == oldSelf
- message: failoverIP must be either 'AUTO' or a valid IPv4
address
rule: self == "" || self == "AUTO" || self.matches("((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$")
rule: self == "AUTO" || self.matches("((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$")
memoryMB:
default: 3072
description: |-
Expand Down
14 changes: 7 additions & 7 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# Adds namespace to all resources.
namePrefix: capic-
namespace: capic-system
Expand All @@ -12,29 +13,28 @@ resources:
- ../manager
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
#- ../webhook
# - ../webhook
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required.
#- ../certmanager
# - ../certmanager
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
#- ../prometheus
# - ../prometheus

patchesStrategicMerge:
- manager_image_patch.yaml



# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
#- manager_webhook_patch.yaml
# - manager_webhook_patch.yaml

# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'.
# Uncomment 'CERTMANAGER' sections in crd/kustomization.yaml to enable the CA injection in the admission webhooks.
# 'CERTMANAGER' needs to be enabled to use ca injection
#- webhookcainjection_patch.yaml
# - webhookcainjection_patch.yaml

# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix.
# Uncomment the following replacements to add the cert-manager CA injection annotations
#replacements:
# replacements:
# - source: # Add cert-manager annotation to ValidatingWebhookConfiguration, MutatingWebhookConfiguration and CRDs
# kind: Certificate
# group: cert-manager.io
Expand Down
1 change: 1 addition & 0 deletions config/default/manager_config_patch.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
1 change: 1 addition & 0 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
resources:
- manager.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
Expand Down
19 changes: 9 additions & 10 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: v1
kind: Namespace
metadata:
Expand Down Expand Up @@ -73,14 +74,14 @@ spec:
image: controller:latest
name: manager
ports:
- containerPort: 8443
name: diagnostics
protocol: TCP
- containerPort: 8443
name: diagnostics
protocol: TCP
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- "ALL"
- "ALL"
livenessProbe:
httpGet:
path: /healthz
Expand Down Expand Up @@ -122,9 +123,7 @@ spec:
selector:
control-plane: controller-manager
ports:
- name: diagnostics-svc
protocol: TCP
port: 8443
targetPort: diagnostics


- name: diagnostics-svc
protocol: TCP
port: 8443
targetPort: diagnostics
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: IonosCloudCluster
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: IonosCloudMachine
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: IonosCloudMachineTemplate
metadata:
Expand Down
3 changes: 2 additions & 1 deletion config/samples/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
## Append samples of your project ##
resources:
- infrastructure_v1alpha1_ionoscloudcluster.yaml
- infrastructure_v1alpha1_ionoscloudmachine.yaml
- infrastructure_v1alpha1_ionoscloudmachinetemplate.yaml
#+kubebuilder:scaffold:manifestskustomizesamples
# +kubebuilder:scaffold:manifestskustomizesamples
20 changes: 12 additions & 8 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,23 @@ CAPIC requires several environment variables to be set in order to create a Kube
They can be exported or saved inside the clusterctl config file at `~/.cluster-api/clusterctl.yaml`

```env
## -- Cloud specific environment variables -- ##
## -- Cloud-specific environment variables -- ##
IONOS_TOKEN # The token of the IONOS Cloud account.
IONOS_API_URL # The API URL of the IONOS Cloud account.
# Defaults to https://api.ionos.com/cloudapi/v6
## -- Cluster API related environment variables -- ##
CONTROL_PLANE_ENDPOINT_IP # The IP address of the control plane endpoint.
CONTROL_PLANE_ENDPOINT_PORT # The port of the control plane endpoint.
IONOS_API_URL # The API URL of the IONOS Cloud account (optional).
# Defaults to https://api.ionos.com/cloudapi/v6.
## -- Cluster API-related environment variables -- ##
CONTROL_PLANE_ENDPOINT_HOST # The control plane endpoint host (optional).
# If it's not an IP but an FQDN, the provider must be able to resolve it
# to the value for CONTROL_PLANE_ENDPOINT_IP.
CONTROL_PLANE_ENDPOINT_IP # The IPv4 address of the control plane endpoint.
CONTROL_PLANE_ENDPOINT_PORT # The port of the control plane endpoint (optional).
# Defaults to 6443.
CONTROL_PLANE_ENDPOINT_LOCATION # The location of the control plane endpoint.
CLUSTER_NAME # The name of the cluster.
KUBERNETES_VERSION # The version of Kubernetes to be installed (can also be set via clusterctl).
## -- Kubernetes Cluster related environment variables -- ##
## -- Kubernetes Cluster-related environment variables -- ##
IONOSCLOUD_CONTRACT_NUMBER # The contract number of the IONOS Cloud contract.
IONOSCLOUD_DATACENTER_ID # The datacenter ID where the cluster should be created.
IONOSCLOUD_MACHINE_NUM_CORES # The number of cores.
Expand Down
1 change: 1 addition & 0 deletions envfile.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export IONOS_API_URL="https://api.ionos.com/cloudapi/v6"


# Cluster API related environment variables
export CONTROL_PLANE_ENDPOINT_HOST="example.org"
export CONTROL_PLANE_ENDPOINT_IP="192.168.0.1"
export CONTROL_PLANE_ENDPOINT_PORT=6443
export CONTROL_PLANE_ENDPOINT_LOCATION="de/txl"
Expand Down
Loading

0 comments on commit 83805dd

Please sign in to comment.