Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: garm runners will be reflected into kubernetes as runner resource #23

Merged
merged 23 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
893804e
feat: initial setup runner-controller reconcile on external events
rafalgalaw Oct 25, 2023
9df3f31
feat: add sync logic for runners
rafalgalaw Nov 1, 2023
0eeb58f
feat: add validation webhook for runner CR
rafalgalaw Nov 1, 2023
a038fb1
feat: add runner_controller_test.go
rafalgalaw Nov 1, 2023
91d1271
fix: remove webhook
rafalgalaw Nov 1, 2023
933a18b
feat: add pool name in kubectl runner output, add agentId. providerId…
rafalgalaw Nov 30, 2023
4ce499b
fix(docs): update adr jwt caching
rafalgalaw Dec 4, 2023
9dd1158
fix(lint): defer calls never executed
rafalgalaw Dec 6, 2023
37b9d0f
chore: bump to go 1.21.5
bavarianbidi Dec 6, 2023
16dde4f
fix rebase issue
bavarianbidi Dec 6, 2023
bd14b70
chore: add comments, add --operator-disable-webhooks flag for local d…
rafalgalaw Dec 6, 2023
be1e759
fix: refactor deletion logic
rafalgalaw Dec 7, 2023
b601b8d
refactor(runner_controller): cleanup code, extract methods
rafalgalaw Dec 8, 2023
c6e08cf
Update docs/config/configuration-parsing.md
rafalgalaw Dec 8, 2023
ae04dcf
Update docs/config/configuration-parsing.md
rafalgalaw Dec 8, 2023
a577f39
Update docs/config/configuration-parsing.md
rafalgalaw Dec 8, 2023
889116a
Update docs/config/configuration-parsing.md
rafalgalaw Dec 8, 2023
3659c47
fix: add test for runner enqueuing, convert provider fault msg, fixes…
rafalgalaw Dec 8, 2023
9fa621d
fix: lint
rafalgalaw Dec 8, 2023
3348bf3
fix: revert jwt_adr
rafalgalaw Dec 8, 2023
a359c3a
fix: providerFault msg
rafalgalaw Dec 8, 2023
f714691
revert JWT ADR change
bavarianbidi Dec 8, 2023
9db59a1
Merge branch 'main' into feat/show-runners
bavarianbidi Dec 11, 2023
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ GOVULNCHECK ?= $(LOCALBIN)/govulncheck
## Tool Versions
KUSTOMIZE_VERSION ?= v5.0.1
CONTROLLER_TOOLS_VERSION ?= v0.12.0
GOLANGCI_LINT_VERSION ?= v1.53.3
GOLANGCI_LINT_VERSION ?= v1.55.2
MOCKGEN_VERSION ?= v0.2.0
GORELEASER_VERSION ?= v1.21.0
MDTOC_VERSION ?= v1.1.0
Expand Down
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,13 @@ resources:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: mercedes-benz.com
group: garm-operator
kind: Runner
path: github.com/mercedes-benz/garm-operator/api/v1alpha1
version: v1alpha1
version: "3"
1 change: 1 addition & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ k8s_resource(
'images.garm-operator.mercedes-benz.com:customresourcedefinition',
'organizations.garm-operator.mercedes-benz.com:customresourcedefinition',
'pools.garm-operator.mercedes-benz.com:customresourcedefinition',
'runners.garm-operator.mercedes-benz.com:customresourcedefinition',
'repositories.garm-operator.mercedes-benz.com:customresourcedefinition',
'garm-operator-controller-manager:serviceaccount',
'garm-operator-leader-election-role:role',
Expand Down
6 changes: 6 additions & 0 deletions api/v1alpha1/pool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ func MatchesGitHubScope(name, kind string) Predicate {
}
}

func MatchesID(id string) Predicate {
return func(p Pool) bool {
return p.Status.ID == id
}
}

func (p *PoolList) FilterByFields(predicates ...Predicate) {
var filteredItems []Pool

Expand Down
108 changes: 108 additions & 0 deletions api/v1alpha1/runner_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// SPDX-License-Identifier: MIT

package v1alpha1

import (
commonParams "github.com/cloudbase/garm-provider-common/params"
"github.com/cloudbase/garm/params"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// RunnerSpec defines the desired state of Runner
type RunnerSpec struct{}

// RunnerStatus defines the observed state of Runner
type RunnerStatus struct {
// ID is the database ID of this instance.
ID string `json:"id,omitempty"`
rafalgalaw marked this conversation as resolved.
Show resolved Hide resolved

// PeoviderID is the unique ID the provider associated
rafalgalaw marked this conversation as resolved.
Show resolved Hide resolved
// with the compute instance. We use this to identify the
// instance in the provider.
ProviderID string `json:"providerId,omitempty"`

// AgentID is the github runner agent ID.
AgentID int64 `json:"agentId"`

// Name is the name associated with an instance. Depending on
// the provider, this may or may not be useful in the context of
// the provider, but we can use it internally to identify the
// instance.
Name string `json:"name,omitempty"`

// OSType is the operating system type. For now, only Linux and
// Windows are supported.
OSType commonParams.OSType `json:"osType,omitempty"`

// OSName is the name of the OS. Eg: ubuntu, centos, etc.
OSName string `json:"osName,omitempty"`

// OSVersion is the version of the operating system.
OSVersion string `json:"osVersion,omitempty"`

// OSArch is the operating system architecture.
OSArch commonParams.OSArch `json:"osArch,omitempty"`

// Addresses is a list of IP addresses the provider reports
// for this instance.
Addresses []commonParams.Address `json:"addresses,omitempty"`

// Status is the status of the instance inside the provider (eg: running, stopped, etc)
Status commonParams.InstanceStatus `json:"status,omitempty"`

// RunnerStatus is the github runner status as it appears on GitHub.
InstanceStatus params.RunnerStatus `json:"instanceStatus,omitempty"`

// PoolID is the ID of the garm pool to which a runner belongs.
PoolID string `json:"poolId,omitempty"`
rafalgalaw marked this conversation as resolved.
Show resolved Hide resolved

// ProviderFault holds any error messages captured from the IaaS provider that is
// responsible for managing the lifecycle of the runner.
ProviderFault string `json:"providerFault,omitempty"`

// StatusMessages is a list of status messages sent back by the runner as it sets itself
// up.

//// UpdatedAt is the timestamp of the last update to this runner.
// UpdatedAt time.Time `json:"updated_at"`

rafalgalaw marked this conversation as resolved.
Show resolved Hide resolved
// GithubRunnerGroup is the github runner group to which the runner belongs.
// The runner group must be created by someone with access to the enterprise.
GitHubRunnerGroup string `json:"githubRunnerGroup"`
}

//+kubebuilder:object:root=true
//+kubebuilder:resource:path=runners,scope=Namespaced,categories=garm,shortName=run
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="ID",type="string",JSONPath=".status.id",description="Runner ID"
//+kubebuilder:printcolumn:name="Pool",type="string",JSONPath=".status.poolId",description="Pool CR Name"
//+kubebuilder:printcolumn:name="Garm Runner Status",type="string",JSONPath=".status.status",description="Garm Runner Status"
//+kubebuilder:printcolumn:name="Provider Runner Status",type="string",JSONPath=".status.instanceStatus",description="Provider Runner Status"
//+kubebuilder:printcolumn:name="Provider ID",type="string",JSONPath=".status.providerId",description="Provider ID",priority=1
//+kubebuilder:printcolumn:name="Agent ID",type="string",JSONPath=".status.agentId",description="Agent ID",priority=1
//+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

rafalgalaw marked this conversation as resolved.
Show resolved Hide resolved
// Runner is the Schema for the runners API
type Runner struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec RunnerSpec `json:"spec,omitempty"`
Status RunnerStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// RunnerList contains a list of Runner
type RunnerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Runner `json:"items"`
}

func init() {
SchemeBuilder.Register(&Runner{}, &RunnerList{})
}
95 changes: 95 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.

Loading