Skip to content

Commit

Permalink
add devbox controller rbac, enable in ci to build docker images (#5009)
Browse files Browse the repository at this point in the history
* add devbox controller rbac, enable in ci to build docker images

* add devbox controller rbac, enable in ci to build docker images

* add devbox controller rbac, enable in ci to build docker images
  • Loading branch information
lingdie authored Aug 29, 2024
1 parent 5877ddb commit 7e77b7a
Show file tree
Hide file tree
Showing 15 changed files with 1,041 additions and 26 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/controllers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ jobs:
- { name: job-heartbeat, path: job/heartbeat }
- { name: resources, path: resources }
- { name: node, path: node }
- { name: devbox, path: devbox}
- { name: objectstorage, path: objectstorage }
steps:
- name: Checkout
Expand Down Expand Up @@ -201,6 +202,7 @@ jobs:
- { name: job-heartbeat, path: job/heartbeat }
- { name: resources, path: resources }
- { name: node, path: node }
- { name: devbox, path: devbox }
- { name: objectstorage, path: objectstorage }
steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions controllers/devbox/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ test: manifests generate fmt vet envtest ## Run tests.

.PHONY: build
build: ## Build manager binary.
CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags "-s -w" -trimpath -o bin/manager main.go
CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags "-s -w" -trimpath -o bin/manager cmd/main.go

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go
go run ./cmd/main.go

.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.15.0
controller-gen.kubebuilder.io/version: v0.14.0
name: devboxes.devbox.sealos.io
spec:
group: devbox.sealos.io
Expand Down Expand Up @@ -90,7 +90,7 @@ spec:
Defaults to "TCP".
type: string
required:
- containerPort
- containerPort
type: object
type: array
type:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.15.0
controller-gen.kubebuilder.io/version: v0.14.0
name: devboxreleases.devbox.sealos.io
spec:
group: devbox.sealos.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.15.0
controller-gen.kubebuilder.io/version: v0.14.0
name: operationrequests.devbox.sealos.io
spec:
group: devbox.sealos.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.15.0
controller-gen.kubebuilder.io/version: v0.14.0
name: runtimeclasses.devbox.sealos.io
spec:
group: devbox.sealos.io
Expand Down Expand Up @@ -57,15 +57,15 @@ spec:
type: string
kind:
enum:
- OS
- Language
- Framework
- OS
- Language
- Framework
type: string
title:
type: string
required:
- kind
- title
- kind
- title
type: object
status:
description: RuntimeClassStatus defines the observed state of RuntimeClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.15.0
controller-gen.kubebuilder.io/version: v0.14.0
name: runtimes.devbox.sealos.io
spec:
group: devbox.sealos.io
Expand Down
2 changes: 1 addition & 1 deletion controllers/devbox/config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: docker.io/lingdie/sealos-devbox-controller
newName: ghcr.io/labring/sealos-devbox-controller
newTag: latest
42 changes: 30 additions & 12 deletions controllers/devbox/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ metadata:
name: manager-role
rules:
- apiGroups:
- devbox.sealos.io
- ""
resources:
- devboxes
- pods
verbs:
- create
- delete
Expand All @@ -31,23 +31,41 @@ rules:
- update
- watch
- apiGroups:
- devbox.sealos.io
- ""
resources:
- devboxes/finalizers
- pods/status
verbs:
- get
- patch
- update
- apiGroups:
- devbox.sealos.io
- ""
resources:
- devboxes/status
- secrets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- services
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- devbox.sealos.io
resources:
- devboxreleases
- devboxes
verbs:
- create
- delete
Expand All @@ -59,21 +77,21 @@ rules:
- apiGroups:
- devbox.sealos.io
resources:
- devboxreleases/finalizers
- devboxes/finalizers
verbs:
- update
- apiGroups:
- devbox.sealos.io
resources:
- devboxreleases/status
- devboxes/status
verbs:
- get
- patch
- update
- apiGroups:
- devbox.sealos.io
resources:
- operationrequests
- devboxreleases
verbs:
- create
- delete
Expand All @@ -85,13 +103,13 @@ rules:
- apiGroups:
- devbox.sealos.io
resources:
- operationrequests/finalizers
- devboxreleases/finalizers
verbs:
- update
- apiGroups:
- devbox.sealos.io
resources:
- operationrequests/status
- devboxreleases/status
verbs:
- get
- patch
Expand Down
13 changes: 13 additions & 0 deletions controllers/devbox/deploy/Kubefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM scratch

USER 65532:65532

COPY registry registry
COPY manifests manifests

ENV registryAddr="sealos.hub:5000"
ENV registryUser=admin
ENV registryPassword=passw0rd
ENV authAddr="sealos.hub:5000"

CMD ["kubectl apply -f manifests"]
Loading

0 comments on commit 7e77b7a

Please sign in to comment.