Skip to content

Commit 3260fde

Browse files
committed
feat: initial implementation
Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
1 parent d793a8a commit 3260fde

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

+2666
-374
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
hack/config/env.yaml
2+
talos-controller-manager

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM scratch
2+
COPY --from=docker.io/autonomy/ca-certificates:febbf49 / /
3+
COPY --from=docker.io/autonomy/fhs:febbf49 / /
4+
COPY ./talos-controller-manager /talos-controller-manager
5+
ENTRYPOINT [ "/talos-controller-manager" ]

LICENSE

Lines changed: 0 additions & 373 deletions
This file was deleted.

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
all: manager container
2+
3+
manager: generate
4+
CGO_ENABLED=0 go build .
5+
6+
.PHONY: generate
7+
generate: # Generate code.
8+
controller-gen object:headerFile=./hack/boilerplate.go.txt paths="./..."
9+
10+
container: # Build a container image.
11+
docker build --tag docker.io/andrewrynhard/talos-controller-manager .
12+
13+
.PHONY: manifests
14+
manifests: # Generate manifests e.g. CRD, RBAC etc.
15+
controller-gen rbac:roleName=talos-controller-manager-role crd paths="./..." output:rbac:artifacts:config=hack/config/rbac output:crd:artifacts:config=hack/config/crd
16+
17+
deploy: manifests # Deploy controller-manager to a cluster.
18+
kubectl apply -k hack/config
19+
20+
destroy: # Remove controller-manager from a cluster.
21+
kubectl delete -k hack/config

README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,47 @@
1-
# talos-operator
1+
# talos-controller-manager
2+
3+
## Getting Started
4+
5+
```bash
6+
kubectl label node -l node-role.kubernetes.io/master='' v1alpha1.upgrade.talos.dev/pool=serial-latest
7+
kubectl label node -l node-role.kubernetes.io/worker='' v1alpha1.upgrade.talos.dev/pool=concurrent-latest
8+
```
9+
10+
```bash
11+
export TOKEN=<token>
12+
cat <<EOF >./hack/config/env.yaml
13+
apiVersion: apps/v1
14+
kind: DaemonSet
15+
metadata:
16+
name: talos-controller-manager
17+
spec:
18+
template:
19+
spec:
20+
containers:
21+
- name: talos-controller-manager
22+
env:
23+
- name: TALOS_TOKEN
24+
value: $TOKEN
25+
EOF
26+
```
27+
28+
```bash
29+
make deploy
30+
```
31+
32+
```bash
33+
kubectl get pods -n talos-system
34+
```
35+
36+
```bash
37+
kubectl apply -f hack/config/examples/pool.yaml
38+
```
39+
40+
```bash
41+
kubectl logs -n talos-system -f $(kubectl get lease -n talos-system talos-controller-manager -o jsonpath='{.spec.holderIdentity}')
42+
```
43+
44+
## TODO
45+
46+
- Upgrade window
47+
- Explicit version (takes precedence over `channel`)

api/v1alpha1/groupversion_info.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright 2019 Talos Systems, Inc..
3+
*/
4+
5+
// Package v1alpha1 contains API Schema definitions for the pool v1alpha1 API group
6+
// +kubebuilder:object:generate=true
7+
// +groupName=upgrade.talos.dev
8+
package v1alpha1
9+
10+
import (
11+
"k8s.io/apimachinery/pkg/runtime/schema"
12+
"sigs.k8s.io/controller-runtime/pkg/scheme"
13+
)
14+
15+
var (
16+
// GroupVersion is group version used to register these objects
17+
GroupVersion = schema.GroupVersion{Group: "upgrade.talos.dev", Version: "v1alpha1"}
18+
19+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
20+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
21+
22+
// AddToScheme adds the types in this group-version to the given scheme.
23+
AddToScheme = SchemeBuilder.AddToScheme
24+
)

api/v1alpha1/pool_types.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Copyright 2019 Talos Systems, Inc..
3+
*/
4+
5+
package v1alpha1
6+
7+
import (
8+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
9+
)
10+
11+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
12+
13+
// PoolSpec defines the desired state of Pool
14+
type PoolSpec struct {
15+
Name string `json:"name,omitempty"`
16+
Channel string `json:"channel,omitempty"`
17+
Registry string `json:"registry,omitempty"`
18+
Repository string `json:"repository,omitempty"`
19+
Concurrency int `json:"concurrency,omitempty"`
20+
FailurePolicy string `json:"onFailure,omitempty"`
21+
CheckInterval *metav1.Duration `json:"checkInterval,omitempty"`
22+
}
23+
24+
// PoolStatus defines the observed state of Pool
25+
type PoolStatus struct {
26+
Size int `json:"size,omitempty"`
27+
InProgress string `json:"inProgess,omitempty"`
28+
}
29+
30+
// +kubebuilder:object:root=true
31+
32+
// Pool is the Schema for the pools API
33+
// +kubebuilder:printcolumn:name="Channel",type="string",JSONPath=".spec.channel",description="the pool's upgrade channel"
34+
// +kubebuilder:printcolumn:name="Size",type="integer",JSONPath=".status.size",description="the number of nodes in the pool"
35+
// +kubebuilder:printcolumn:name="Concurrency",type="string",JSONPath=".spec.concurrency",description="the pool's maximum number of concurrent upgrades"
36+
// +kubebuilder:printcolumn:name="In Progress",type="string",JSONPath=".status.inProgess",description="the nodes in the pool that are currently in progress of upgrading"
37+
type Pool struct {
38+
metav1.TypeMeta `json:",inline"`
39+
metav1.ObjectMeta `json:"metadata,omitempty"`
40+
41+
Spec PoolSpec `json:"spec,omitempty"`
42+
Status PoolStatus `json:"status,omitempty"`
43+
}
44+
45+
// +kubebuilder:object:root=true
46+
47+
// PoolList contains a list of Pool
48+
type PoolList struct {
49+
metav1.TypeMeta `json:",inline"`
50+
metav1.ListMeta `json:"metadata,omitempty"`
51+
Items []Pool `json:"items"`
52+
}
53+
54+
func init() {
55+
SchemeBuilder.Register(&Pool{}, &PoolList{})
56+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 104 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module github.com/talos-systems/talos-controller-manager
2+
3+
go 1.13
4+
5+
require (
6+
github.com/blang/semver v3.5.0+incompatible
7+
github.com/docker/distribution v2.7.1+incompatible
8+
github.com/docker/go-metrics v0.0.1 // indirect
9+
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
10+
github.com/go-logr/logr v0.1.0
11+
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect
12+
github.com/gorilla/mux v1.7.3 // indirect
13+
github.com/hashicorp/go-multierror v1.0.0
14+
github.com/hashicorp/golang-lru v0.5.3 // indirect
15+
github.com/imdario/mergo v0.3.8 // indirect
16+
github.com/kubernetes-incubator/bootkube v0.14.1-0.20190731222813-f0fc1bdb404d // indirect
17+
github.com/onsi/ginkgo v1.10.1
18+
github.com/onsi/gomega v1.7.0
19+
github.com/opencontainers/go-digest v1.0.0-rc1
20+
github.com/pkg/errors v0.8.1
21+
github.com/prometheus/client_golang v1.2.1 // indirect
22+
github.com/talos-systems/talos v0.3.0-alpha.9.0.20191129203523-ad2f2574d7e7
23+
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
24+
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
25+
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect
26+
google.golang.org/appengine v1.6.5 // indirect
27+
google.golang.org/grpc v1.25.1
28+
k8s.io/api v0.0.0-20191109101513-0171b7c15da1
29+
k8s.io/apiextensions-apiserver v0.0.0-20191108071732-08c66a398f44 // indirect
30+
k8s.io/apimachinery v0.0.0-20191111054156-6eb29fdf75dc
31+
k8s.io/client-go v0.0.0-20191108070106-f8f007fd456c
32+
sigs.k8s.io/controller-runtime v0.3.1-0.20191105233659-81842d0e78f7
33+
)

0 commit comments

Comments
 (0)