Skip to content

Commit ac5d467

Browse files
committed
feat: first commit
Signed-off-by: Spencer Smith <[email protected]>
0 parents  commit ac5d467

Some content is hidden

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

43 files changed

+1856
-0
lines changed

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
# Binaries for programs and plugins
3+
*.exe
4+
*.exe~
5+
*.dll
6+
*.so
7+
*.dylib
8+
bin
9+
10+
# Test binary, build with `go test -c`
11+
*.test
12+
13+
# Output of the go coverage tool, specifically when used with LiteIDE
14+
*.out
15+
16+
# Kubernetes Generated files - skip generated files, except for vendored files
17+
18+
!vendor/**/zz_generated.*
19+
20+
# editor and IDE paraphernalia
21+
.idea
22+
*.swp
23+
*.swo
24+
*~

Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Build the manager binary
2+
FROM golang:1.12.10 as builder
3+
4+
WORKDIR /workspace
5+
ENV GOPROXY https://proxy.golang.org
6+
# Copy the Go Modules manifests
7+
COPY go.mod go.mod
8+
COPY go.sum go.sum
9+
# cache deps before building and copying source so that we don't need to re-download as much
10+
# and so that source changes don't invalidate our downloaded layer
11+
RUN go mod download
12+
13+
# Copy the go source
14+
COPY main.go main.go
15+
COPY api/ api/
16+
COPY controllers/ controllers/
17+
18+
# Build
19+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
20+
21+
# Use distroless as minimal base image to package the manager binary
22+
# Refer to https://github.com/GoogleContainerTools/distroless for more details
23+
FROM gcr.io/distroless/static:latest
24+
WORKDIR /
25+
COPY --from=builder /workspace/manager .
26+
ENTRYPOINT ["/manager"]

Makefile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
# Image URL to use all building/pushing image targets
3+
IMG ?= rsmitty/cluster-api-talos-controller:latest
4+
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
5+
CRD_OPTIONS ?= "crd:trivialVersions=true"
6+
7+
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
8+
ifeq (,$(shell go env GOBIN))
9+
GOBIN=$(shell go env GOPATH)/bin
10+
else
11+
GOBIN=$(shell go env GOBIN)
12+
endif
13+
14+
all: manager
15+
16+
# Run tests
17+
test: generate fmt vet manifests
18+
go test ./... -coverprofile cover.out
19+
20+
# Build manager binary
21+
manager: generate fmt vet
22+
go build -o bin/manager main.go
23+
24+
# Run against the configured Kubernetes cluster in ~/.kube/config
25+
run: generate fmt vet manifests
26+
go run ./main.go
27+
28+
# Install CRDs into a cluster
29+
install: manifests
30+
kustomize build config/crd | kubectl apply -f -
31+
32+
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
33+
deploy: manifests
34+
cd config/manager && kustomize edit set image controller=${IMG}
35+
kustomize build config/default | kubectl apply -f -
36+
37+
# Generate manifests e.g. CRD, RBAC etc.
38+
manifests: controller-gen
39+
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
40+
41+
# Run go fmt against code
42+
fmt:
43+
go fmt ./...
44+
45+
# Run go vet against code
46+
vet:
47+
go vet ./...
48+
49+
# Generate code
50+
generate: controller-gen
51+
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths="./..."
52+
53+
# Build the docker image
54+
docker-build: generate fmt vet manifests
55+
docker build . -t ${IMG}
56+
57+
# Push the docker image
58+
docker-push:
59+
docker push ${IMG}
60+
61+
# find or download controller-gen
62+
# download controller-gen if necessary
63+
controller-gen:
64+
ifeq (, $(shell which controller-gen))
65+
go get sigs.k8s.io/controller-tools/cmd/[email protected]
66+
CONTROLLER_GEN=$(GOBIN)/controller-gen
67+
else
68+
CONTROLLER_GEN=$(shell which controller-gen)
69+
endif

PROJECT

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: "2"
2+
domain: cluster.x-k8s.io
3+
repo: github.com/talos-systems/cluster-api-bootstrap-provider-talos
4+
resources:
5+
- group: bootstrap
6+
version: v1alpha2
7+
kind: TalosConfig

api/v1alpha2/groupversion_info.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
// Package v1alpha2 contains API Schema definitions for the bootstrap v1alpha2 API group
17+
// +kubebuilder:object:generate=true
18+
// +groupName=bootstrap.cluster.x-k8s.io
19+
package v1alpha2
20+
21+
import (
22+
"k8s.io/apimachinery/pkg/runtime/schema"
23+
"sigs.k8s.io/controller-runtime/pkg/scheme"
24+
)
25+
26+
var (
27+
// GroupVersion is group version used to register these objects
28+
GroupVersion = schema.GroupVersion{Group: "bootstrap.cluster.x-k8s.io", Version: "v1alpha2"}
29+
30+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
31+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
32+
33+
// AddToScheme adds the types in this group-version to the given scheme.
34+
AddToScheme = SchemeBuilder.AddToScheme
35+
)

api/v1alpha2/talosconfig_types.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
package v1alpha2
17+
18+
import (
19+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
20+
)
21+
22+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
23+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
24+
25+
// TalosConfigSpec defines the desired state of TalosConfig
26+
type TalosConfigSpec struct {
27+
MachineType string `json:"machineType,omitempty"`
28+
// Important: Run "make" to regenerate code after modifying this file
29+
}
30+
31+
// TalosConfigStatus defines the observed state of TalosConfig
32+
type TalosConfigStatus struct {
33+
// Ready indicates the BootstrapData field is ready to be consumed
34+
Ready bool `json:"ready,omitempty"`
35+
36+
// BootstrapData will be a slice of bootstrap data
37+
// +optional
38+
BootstrapData []byte `json:"bootstrapData,omitempty"`
39+
40+
// Talos config will be a string containing the config for download
41+
// +optional
42+
TalosConfig string `json:"talosConfig,omitempty"`
43+
44+
// ErrorReason will be set on non-retryable errors
45+
// +optional
46+
ErrorReason string `json:"errorReason,omitempty"`
47+
48+
// ErrorMessage will be set on non-retryable errors
49+
// +optional
50+
ErrorMessage string `json:"errorMessage,omitempty"`
51+
}
52+
53+
// +kubebuilder:object:root=true
54+
// +kubebuilder:storageversion
55+
// +kubebuilder:resource:path=talosconfigs,scope=Namespaced,categories=cluster-api
56+
// +kubebuilder:subresource:status
57+
58+
// TalosConfig is the Schema for the talosconfigs API
59+
type TalosConfig struct {
60+
metav1.TypeMeta `json:",inline"`
61+
metav1.ObjectMeta `json:"metadata,omitempty"`
62+
63+
Spec TalosConfigSpec `json:"spec,omitempty"`
64+
Status TalosConfigStatus `json:"status,omitempty"`
65+
}
66+
67+
// +kubebuilder:object:root=true
68+
69+
// TalosConfigList contains a list of TalosConfig
70+
type TalosConfigList struct {
71+
metav1.TypeMeta `json:",inline"`
72+
metav1.ListMeta `json:"metadata,omitempty"`
73+
Items []TalosConfig `json:"items"`
74+
}
75+
76+
func init() {
77+
SchemeBuilder.Register(&TalosConfig{}, &TalosConfigList{})
78+
}

api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 118 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# The following manifests contain a self-signed issuer CR and a certificate CR.
2+
# More document can be found at https://docs.cert-manager.io
3+
apiVersion: certmanager.k8s.io/v1alpha1
4+
kind: Issuer
5+
metadata:
6+
name: selfsigned-issuer
7+
namespace: system
8+
spec:
9+
selfSigned: {}
10+
---
11+
apiVersion: certmanager.k8s.io/v1alpha1
12+
kind: Certificate
13+
metadata:
14+
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
15+
namespace: system
16+
spec:
17+
# $(SERVICE_NAME) and $(SERVICE_NAMESPACE) will be substituted by kustomize
18+
commonName: $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc
19+
dnsNames:
20+
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local
21+
issuerRef:
22+
kind: Issuer
23+
name: selfsigned-issuer
24+
secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
resources:
2+
- certificate.yaml
3+
4+
configurations:
5+
- kustomizeconfig.yaml

0 commit comments

Comments
 (0)