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

Aio arm #16

Merged
merged 7 commits into from
Aug 29, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 22 additions & 5 deletions .github/workflows/cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,28 @@ jobs:
sed -i "s#labring#${{ github.repository_owner }}#g" etc/sealos/desktop-config.yaml
sed -i "s#latest#${BuildFromTag}#g" init.sh
sed -i "s#latest#${BuildFromTag}#g" etc/sealos/desktop-config.yaml
sudo bash init.sh
sudo sealos build -t ${{ steps.prepare.outputs.repo }}:${{ steps.prepare.outputs.tag_name }} -f Kubefile
sudo sealos build -t ${{ steps.prepare.outputs.repo }}:latest -f Kubefile
sudo sealos push ${{ steps.prepare.outputs.repo }}:${{ steps.prepare.outputs.tag_name }}
sudo sealos push ${{ steps.prepare.outputs.repo }}:latest

sudo bash init.sh amd64
sudo sealos build -t ${{ steps.prepare.outputs.repo }}:${{ steps.prepare.outputs.tag_name }}-amd64 -f Kubefile
sudo sealos build -t ${{ steps.prepare.outputs.repo }}:latest-amd64 -f Kubefile


# delete old registry cache
sudo rm -rf registry
sudo rm -rf tars

sudo bash init.sh arm64
sudo sealos build -t ${{ steps.prepare.outputs.repo }}:${{ steps.prepare.outputs.tag_name }}-arm64 -f Kubefile
sudo sealos build -t ${{ steps.prepare.outputs.repo }}:latest-arm64 -f Kubefile

- name: Manifest Cluster Images
# if push to master, then patch images to ghcr.io
run: |
sudo sealos images
bash docker/patch/manifest-cluster-images.sh ${{ steps.prepare.outputs.repo }}:${{ steps.prepare.outputs.tag_name }}
bash docker/patch/manifest-cluster-images.sh ${{ steps.prepare.outputs.repo }}:latest
env:
OWNER: ${{ github.repository_owner }}

# todo: build multi-arch images

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
matrix:
module:
[
providers/cronjob,
providers/template,
providers/adminer,
providers/applaunchpad,
Expand Down
5 changes: 1 addition & 4 deletions cmd/sealctl/cmd/static_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ func newStaticPodCmd() *cobra.Command {
var staticPodCmd = &cobra.Command{
Use: "static-pod",
Short: "generator static pod",
//Run: func(cmd *cobra.Command, args []string) {
//
//},
}
// check route for host
staticPodCmd.AddCommand(newLvscareCmd())
staticPodCmd.PersistentFlags().StringVar(&staticPodPath, "path", constants.KubernetesEtcStaticPod, "default kubernetes static pod path")
staticPodCmd.PersistentFlags().StringVar(&staticPodPath, "path", "/etc/kubernetes/manifests", "default kubernetes static pod path")
return staticPodCmd
}

Expand Down
39 changes: 27 additions & 12 deletions cmd/sealos/cmd/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@
package cmd

import (
"errors"
"fmt"
"path"
"strings"

"github.com/spf13/cobra"

"github.com/labring/sealos/pkg/apply/processor"
"github.com/labring/sealos/pkg/clusterfile"
"github.com/labring/sealos/pkg/constants"
"github.com/labring/sealos/pkg/runtime/kubernetes"
fileutils "github.com/labring/sealos/pkg/utils/file"
)

var altNames string

func newCertCmd() *cobra.Command {
var altNames []string

cmd := &cobra.Command{
Use: "cert",
Short: "update Kubernetes API server's cert",
Expand All @@ -52,26 +53,40 @@ func newCertCmd() *cobra.Command {
processor.SyncNewVersionConfig(cluster.Name)
clusterPath := constants.Clusterfile(cluster.Name)

pathResolver := constants.NewPathResolver(cluster.Name)

var kubeadmInitFilepath string

for _, f := range []string{
path.Join(pathResolver.ConfigsPath(), "kubeadm-init.yaml"),
path.Join(pathResolver.EtcPath(), "kubeadm-init.yaml"),
} {
if fileutils.IsExist(f) {
kubeadmInitFilepath = f
break
}
}
if kubeadmInitFilepath == "" {
return errors.New("cannot locate the default kubeadm-init.yaml file")
}

cf := clusterfile.NewClusterFile(clusterPath,
clusterfile.WithCustomKubeadmFiles([]string{path.Join(constants.NewData(cluster.Name).EtcPath(), constants.DefaultInitKubeadmFileName)}),
clusterfile.WithCustomKubeadmFiles([]string{kubeadmInitFilepath}),
)
if err = cf.Process(); err != nil {
return err
}
// TODO: using different runtime
rt, err := kubernetes.New(cluster, cf.GetKubeadmConfig())
if err != nil {
return fmt.Errorf("get default runtime failed, %v", err)
}
return rt.UpdateCert(strings.Split(altNames, ","))
},
PreRunE: func(cmd *cobra.Command, args []string) error {
if strings.TrimSpace(altNames) == "" {
return fmt.Errorf("this command alt-names param can't empty")
}
return nil
return rt.UpdateCertSANs(altNames)
},
}
cmd.Flags().StringVarP(&clusterName, "cluster", "c", "default", "name of cluster to applied exec action")
cmd.Flags().StringVar(&altNames, "alt-names", "", "add domain or ip in certs, sealos.io or 10.103.97.2")
cmd.Flags().StringSliceVar(&altNames, "alt-names", []string{}, "add extra Subject Alternative Names for certs, domain or ip, eg. sealos.io or 10.103.97.2")
_ = cmd.MarkFlagRequired("alt-names")

return cmd
}
2 changes: 1 addition & 1 deletion cmd/sealos/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func onBootOnDie() {

var rootDirs = []string{
constants.LogPath(),
constants.Workdir(),
constants.WorkDir(),
}
errExit(file.MkDirs(rootDirs...))
}
Expand Down
1 change: 1 addition & 0 deletions controllers/account/config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ webhooks:
name: webhook-service
namespace: system
path: /validate-v1-sealos-cloud
timeoutSeconds: 10
failurePolicy: Ignore
name: debt.sealos.io
rules:
Expand Down
10 changes: 10 additions & 0 deletions controllers/account/deploy/manifests/deploy.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,7 @@ webhooks:
name: account-webhook-service
namespace: account-system
path: /validate-v1-sealos-cloud
timeoutSeconds: 10
failurePolicy: Ignore
name: debt.sealos.io
namespaceSelector:
Expand All @@ -1317,4 +1318,13 @@ webhooks:
- DELETE
resources:
- '*'
- apiGroups:
- account.sealos.io
apiVersions:
- v1
operations:
- UPDATE
resources:
- payments/status
scope: '*'
sideEffects: None
46 changes: 37 additions & 9 deletions controllers/node/controllers/gpu_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/source"
)

type GpuReconciler struct {
Expand Down Expand Up @@ -108,16 +110,18 @@ func (r *GpuReconciler) applyGPUInfoCM(ctx context.Context, nodeList *corev1.Nod
}
// get the number of GPU used by pods that are using GPU
for _, pod := range podList.Items {
phase := pod.Status.Phase
if phase == corev1.PodSucceeded {
continue
}

nodeName = pod.Spec.NodeName
_, ok1 := nodeMap[nodeName]
gpuProduct, ok2 := pod.Spec.NodeSelector[NvidiaGPUProduct]
if !ok1 || !ok2 {
continue
}
phase := pod.Status.Phase
if phase != corev1.PodRunning {
continue
}

containers := pod.Spec.Containers
for _, container := range containers {
gpuCount, ok := container.Resources.Limits[NvidiaGPU]
Expand Down Expand Up @@ -249,7 +253,7 @@ func (r *GpuReconciler) SetupWithManager(mgr ctrl.Manager) error {
if _, ok := pod.Spec.NodeSelector[NvidiaGPUProduct]; !ok {
return nil
}
if pod.Status.Phase != corev1.PodRunning {
if pod.Status.Phase == corev1.PodSucceeded {
return nil
}
return []string{GPU}
Expand All @@ -260,8 +264,7 @@ func (r *GpuReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&corev1.Pod{}, builder.WithPredicates(predicate.Funcs{
CreateFunc: func(event event.CreateEvent) bool {
_, ok := event.Object.(*corev1.Pod).Spec.NodeSelector[NvidiaGPUProduct]
return ok
return useGPU(event.Object)
},
UpdateFunc: func(event event.UpdateEvent) bool {
_, ok := event.ObjectNew.(*corev1.Pod).Spec.NodeSelector[NvidiaGPUProduct]
Expand All @@ -273,9 +276,34 @@ func (r *GpuReconciler) SetupWithManager(mgr ctrl.Manager) error {
return phaseOld != phaseNew
},
DeleteFunc: func(event event.DeleteEvent) bool {
_, ok := event.Object.(*corev1.Pod).Spec.NodeSelector[NvidiaGPUProduct]
return ok
return useGPU(event.Object)
},
})).
Watches(&source.Kind{Type: &corev1.Node{}}, &handler.EnqueueRequestForObject{}, builder.WithPredicates(predicate.Funcs{
CreateFunc: func(event event.CreateEvent) bool {
return hasGPU(event.Object)
},
UpdateFunc: func(event event.UpdateEvent) bool {
oldVal, oldOk := event.ObjectOld.(*corev1.Node).Status.Allocatable[NvidiaGPU]
newVal, newOk := event.ObjectNew.(*corev1.Node).Status.Allocatable[NvidiaGPU]

return oldOk && newOk && oldVal != newVal
},
DeleteFunc: func(event event.DeleteEvent) bool {
return hasGPU(event.Object)
},
})).
Complete(r)
}

func useGPU(obj client.Object) bool {
_, ok := obj.(*corev1.Pod).Spec.NodeSelector[NvidiaGPUProduct]
return ok
}

func hasGPU(obj client.Object) bool {
_, ok1 := obj.(*corev1.Node).Labels[NvidiaGPUMemory]
_, ok2 := obj.(*corev1.Node).Labels[NvidiaGPUProduct]
_, ok3 := obj.(*corev1.Node).Status.Allocatable[NvidiaGPU]
return ok1 && ok2 && ok3
}
27 changes: 14 additions & 13 deletions deploy/cloud/init.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#!/bin/bash
export readonly ARCH=${1:-amd64}
mkdir -p tars
sealos pull --policy=always ghcr.io/labring/sealos-cloud-user-controller:latest
sealos pull --policy=always ghcr.io/labring/sealos-cloud-terminal-controller:latest
sealos pull --policy=always ghcr.io/labring/sealos-cloud-app-controller:latest
sealos pull --policy=always ghcr.io/labring/sealos-cloud-desktop-frontend:latest
sealos pull --policy=always ghcr.io/labring/sealos-cloud-terminal-frontend:latest
sealos pull --policy=always ghcr.io/labring/sealos-cloud-applaunchpad-frontend:latest
sealos pull --policy=always ghcr.io/labring/sealos-cloud-dbprovider-frontend:latest
sealos pull --policy=always ghcr.io/labring/sealos-cloud-resources-metering-controller:latest
sealos pull --policy=always ghcr.io/labring/sealos-cloud-resources-controller:latest
sealos pull --policy=always ghcr.io/labring/sealos-cloud-account-controller:latest
sealos pull --policy=always ghcr.io/labring/sealos-cloud-costcenter-frontend:latest
sealos pull --policy=always ghcr.io/labring/sealos-cloud-licenseissuer-controller:latest
sealos pull --policy=always ghcr.io/labring/sealos-cloud-template-frontend:latest
sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-user-controller:latest
sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-terminal-controller:latest
sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-app-controller:latest
sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-desktop-frontend:latest
sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-terminal-frontend:latest
sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-applaunchpad-frontend:latest
sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-dbprovider-frontend:latest
sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-resources-metering-controller:latest
sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-resources-controller:latest
sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-account-controller:latest
sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-costcenter-frontend:latest
sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-licenseissuer-controller:latest
sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-template-frontend:latest

sealos save -o tars/user.tar ghcr.io/labring/sealos-cloud-user-controller:latest
sealos save -o tars/terminal.tar ghcr.io/labring/sealos-cloud-terminal-controller:latest
Expand Down
3 changes: 2 additions & 1 deletion frontend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ buildTargets := \
providers/dbprovider \
providers/applaunchpad \
providers/imagehub \
providers/template
providers/template \
providers/cronjob

buildTargets-all := $(addprefix image-build-,$(buildTargets))
pushTargets-all := $(addprefix image-push-,$(buildTargets))
Expand Down
Binary file removed frontend/desktop/public/images/background.png
Binary file not shown.