Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@bazel_gazelle//:def.bzl", "gazelle")
load("//build:run_in_workspace_with_goroot.bzl", "workspace_binary")

Expand All @@ -20,3 +21,25 @@ workspace_binary(
args = ["run --fast=false"],
cmd = "@com_github_golangci_golangci-lint//cmd/golangci-lint",
)

go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "sigs.k8s.io/cluster-api",
visibility = ["//visibility:private"],
deps = [
"//api/v1alpha2:go_default_library",
"//controllers:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/klog/klogr:go_default_library",
"//vendor/sigs.k8s.io/controller-runtime:go_default_library",
],
)

go_binary(
name = "cluster-api-manager",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,25 @@
# limitations under the License.

# Build the manager binary
FROM golang:1.12.6 as builder
FROM golang:1.12.7 as builder

ARG ARCH

# Copy in the go src
WORKDIR ${GOPATH}/src/sigs.k8s.io/cluster-api
COPY pkg/ pkg/
COPY cmd/ cmd/
COPY pkg/ pkg/
COPY cmd/ cmd/
COPY api/ api/
COPY controllers/ controllers/
COPY vendor/ vendor/
COPY go.mod go.mod
COPY go.sum go.sum
COPY main.go main.go

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GO111MODULE=on GOFLAGS="-mod=vendor" \
go build -a -ldflags '-extldflags "-static"' \
-o manager sigs.k8s.io/cluster-api/cmd/manager
-o manager .

# Copy the controller-manager into a thin image
FROM gcr.io/distroless/static:latest
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,17 @@ generate: ## Generate code
.PHONY: generate-deepcopy
generate-deepcopy: ## Runs controller-gen to generate deepcopy files
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go \
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \
paths=./pkg/...
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \
paths=./api/...

.PHONY: generate-manifests
generate-manifests: ## Generate manifests e.g. CRD, RBAC etc.
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go \
paths=./pkg/... \
paths=./api/... \
paths=./pkg/controller/... \
crd:trivialVersions=true \
rbac:roleName=manager-role \
output:crd:dir=./config/crds
output:crd:dir=./config/crd/bases
## Copy files in CI folders.
cp -f ./config/rbac/role*.yaml ./config/ci/rbac/
cp -f ./config/manager/manager*.yaml ./config/ci/manager/
Expand Down
15 changes: 14 additions & 1 deletion PROJECT
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
version: "1"
version: "2"
domain: x-k8s.io
repo: sigs.k8s.io/cluster-api
resources:
- group: cluster
version: v1alpha2
kind: Cluster
- group: cluster
version: v1alpha2
kind: Machine
- group: cluster
version: v1alpha2
kind: MachineSet
- group: cluster
version: v1alpha2
kind: MachineDeployment
30 changes: 3 additions & 27 deletions pkg/apis/cluster/v1alpha2/BUILD.bazel → api/v1alpha2/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
Expand All @@ -7,15 +7,14 @@ go_library(
"cluster_types.go",
"common_types.go",
"defaults.go",
"doc.go",
"groupversion_info.go",
"machine_phase_types.go",
"machine_types.go",
"machinedeployment_types.go",
"machineset_types.go",
"register.go",
"zz_generated.deepcopy.go",
],
importpath = "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha2",
importpath = "sigs.k8s.io/cluster-api/api/v1alpha2",
visibility = ["//visibility:public"],
deps = [
"//pkg/errors:go_default_library",
Expand All @@ -30,26 +29,3 @@ go_library(
"//vendor/sigs.k8s.io/controller-runtime/pkg/scheme:go_default_library",
],
)

go_test(
name = "go_default_test",
srcs = [
"cluster_types_test.go",
"machine_types_test.go",
"machinedeployment_types_test.go",
"machineset_types_test.go",
"v1alpha2_suite_test.go",
],
embed = [":go_default_library"],
deps = [
"//vendor/github.com/onsi/gomega:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library",
"//vendor/sigs.k8s.io/controller-runtime/pkg/envtest:go_default_library",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,6 @@ const (
ClusterAnnotationControlPlaneReady = "cluster.x-k8s.io/control-plane-ready"
)

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

/// [Cluster]
// Cluster is the Schema for the clusters API
// +k8s:openapi-gen=true
// +kubebuilder:resource:path=clusters,shortName=cl
// +kubebuilder:storageversion
// +kubebuilder:subresource:status
type Cluster struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ClusterSpec `json:"spec,omitempty"`
Status ClusterStatus `json:"status,omitempty"`
}

/// [Cluster]

/// [ClusterSpec]
// ClusterSpec defines the desired state of Cluster
type ClusterSpec struct {
Expand Down Expand Up @@ -148,7 +129,21 @@ type APIEndpoint struct {

/// [APIEndpoint]

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=clusters,shortName=cl,scope=Namespaced
// +kubebuilder:storageversion
// +kubebuilder:subresource:status

// Cluster is the Schema for the clusters API
type Cluster struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ClusterSpec `json:"spec,omitempty"`
Status ClusterStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// ClusterList contains a list of Cluster
type ClusterList struct {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// NOTE: Boilerplate only. Ignore this file.

// Package v1alpha2 contains API Schema definitions for the cluster v1alpha2 API group
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen=package,register
// +k8s:conversion-gen=sigs.k8s.io/cluster-api/pkg/apis/cluster
// +k8s:defaulter-gen=TypeMeta
// +kubebuilder:object:generate=true
// +groupName=cluster.x-k8s.io
package v1alpha2

Expand All @@ -30,17 +25,12 @@ import (
)

var (
// SchemeGroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: "cluster.x-k8s.io", Version: "v1alpha2"}
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "cluster.x-k8s.io", Version: "v1alpha2"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme is required by pkg/client/...
// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)

// Resource is required by pkg/client/listers/...
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,6 @@ const (
MachineControlPlaneLabelName = "cluster.x-k8s.io/control-plane"
)

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

/// [Machine]
// Machine is the Schema for the machines API
// +k8s:openapi-gen=true
// +kubebuilder:resource:path=machines,shortName=ma
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +kubebuilder:printcolumn:name="ProviderID",type="string",JSONPath=".spec.providerID",description="Provider ID"
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase",description="Machine status such as Terminating/Pending/Running/Failed etc"
// +kubebuilder:printcolumn:name="NodeName",type="string",JSONPath=".status.nodeRef.name",description="Node name associated with this machine",priority=1
type Machine struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec MachineSpec `json:"spec,omitempty"`
Status MachineStatus `json:"status,omitempty"`
}

/// [Machine]

/// [MachineSpec]
// MachineSpec defines the desired state of Machine
type MachineSpec struct {
Expand Down Expand Up @@ -91,6 +69,9 @@ type MachineSpec struct {
ProviderID *string `json:"providerID,omitempty"`
}

/// [MachineSpec]

/// [MachineStatus]
// MachineStatus defines the observed state of Machine
type MachineStatus struct {
// NodeRef will point to the corresponding Node if it exists.
Expand Down Expand Up @@ -188,6 +169,9 @@ func (m *MachineStatus) GetTypedPhase() MachinePhase {
}
}

/// [MachineStatus]

/// [Bootstrap]
// Bootstrap capsulates fields to configure the Machine’s bootstrapping mechanism.
type Bootstrap struct {
// ConfigRef is a reference to a bootstrap provider-specific resource
Expand All @@ -203,7 +187,29 @@ type Bootstrap struct {
Data *string `json:"data,omitempty"`
}

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

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=machines,shortName=ma,scope=Namespaced
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +kubebuilder:printcolumn:name="ProviderID",type="string",JSONPath=".spec.providerID",description="Provider ID"
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase",description="Machine status such as Terminating/Pending/Running/Failed etc"
// +kubebuilder:printcolumn:name="NodeName",type="string",JSONPath=".status.nodeRef.name",description="Node name associated with this machine",priority=1

/// [Machine]
// Machine is the Schema for the machines API
type Machine struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec MachineSpec `json:"spec,omitempty"`
Status MachineStatus `json:"status,omitempty"`
}

/// [Machine]

// +kubebuilder:object:root=true

// MachineList contains a list of Machine
type MachineList struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,14 @@ type MachineDeploymentStatus struct {

/// [MachineDeploymentStatus]

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

/// [MachineDeployment]
// MachineDeployment is the Schema for the machinedeployments API
// +k8s:openapi-gen=true
// +kubebuilder:resource:path=machinedeployments,shortName=md
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=machinedeployments,shortName=md,scope=Namespaced
// +kubebuilder:storageversion
// +kubebuilder:subresource:status
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.labelSelector

/// [MachineDeployment]
// MachineDeployment is the Schema for the machinedeployments API
type MachineDeployment struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -188,7 +186,7 @@ type MachineDeployment struct {

/// [MachineDeployment]

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true

// MachineDeploymentList contains a list of MachineDeployment
type MachineDeploymentList struct {
Expand Down
Loading