Skip to content

Commit

Permalink
Merge remote-tracking branch 'labring/main' into mv-9
Browse files Browse the repository at this point in the history
  • Loading branch information
lingdie committed Oct 23, 2023
2 parents 94b5761 + 93961f7 commit 110aee0
Show file tree
Hide file tree
Showing 13 changed files with 275 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ jobs:
- name: Run Linter
uses: golangci/golangci-lint-action@v3
with:
version: latest
version: v1.54.2
working-directory: ${{ matrix.workdir }}
args: "--out-${NO_FUTURE}format colored-line-number"
19 changes: 19 additions & 0 deletions CHANGELOG/CHANGELOG-4.3.6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Welcome to the v4.3.6 release of Sealos!🎉🎉!



## Changelog
### Bug fixes
* 34236b4ef946e09ebf695cc7640fb33cf87f5353: fix: create new container mount when force override (#4068) (#4072) (#4079) (@cuisongliu)
### Other work
* a2719848e02e5a00ffa7718243bfaf8801d77669: :bug: set default http sync registry (#4120) (@cuisongliu)
* ff6ac8ce09d66a4da123d714df8c8c13648487a4: Fix conflicts (#4065) (@muicoder)
* b5efb5997988d7be74a042781e7a8008bfcecab9: fix sync image (#4119) (@bxy4543)

**Full Changelog**: https://github.com/labring/sealos/compare/v4.3.5...v4.3.6

See [the CHANGELOG](https://github.com/labring/sealos/blob/main/CHANGELOG/CHANGELOG.md) for more details.

Your patronage towards Sealos is greatly appreciated 🎉🎉.

If you encounter any problems during its usage, please create an issue in the [GitHub repository](https://github.com/labring/sealos), we're committed to resolving your problem as soon as possible.
15 changes: 15 additions & 0 deletions CHANGELOG/CHANGELOG-4.3.7-rc1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Welcome to the v4.3.7-rc1 release of Sealos!🎉🎉!



## Changelog
### Other work
* fef14bea9df8b36ec124e1a66a950fd12d2ae462: :bug: support env for export (#4135) (@cuisongliu)

**Full Changelog**: https://github.com/labring/sealos/compare/v4.3.6...v4.3.7-rc1

See [the CHANGELOG](https://github.com/labring/sealos/blob/main/CHANGELOG/CHANGELOG.md) for more details.

Your patronage towards Sealos is greatly appreciated 🎉🎉.

If you encounter any problems during its usage, please create an issue in the [GitHub repository](https://github.com/labring/sealos), we're committed to resolving your problem as soon as possible.
2 changes: 2 additions & 0 deletions CHANGELOG/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ All notable changes to this project will be documented in this file.
- [CHANGELOG-4.4.0-beta1.md](./CHANGELOG-4.4.0-beta1.md)
- [CHANGELOG-4.4.0-alpha3.md](./CHANGELOG-4.4.0-alpha3.md)
- [CHANGELOG-4.4.0-alpha1.md](./CHANGELOG-4.4.0-alpha1.md)
- [CHANGELOG-4.3.7-rc1.md](./CHANGELOG-4.3.7-rc1.md)
- [CHANGELOG-4.3.6.md](./CHANGELOG-4.3.6.md)
- [CHANGELOG-4.3.5.md](./CHANGELOG-4.3.5.md)
- [CHANGELOG-4.3.4.md](./CHANGELOG-4.3.4.md)
- [CHANGELOG-4.3.3.md](./CHANGELOG-4.3.3.md)
Expand Down
6 changes: 3 additions & 3 deletions booter/pkg/guest/guest.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewGuestManager() (Interface, error) {
}

func (d *Default) Apply(cluster *v2.Cluster, mounts []v2.MountImage, targetHosts []string) error {
envWrapper := env.NewEnvProcessor(cluster)
envGetter := env.NewEnvProcessor(cluster)
sshClient := ssh.NewCacheClientFromCluster(cluster, true)
execer, err := exec.New(sshClient)
if err != nil {
Expand All @@ -56,7 +56,7 @@ func (d *Default) Apply(cluster *v2.Cluster, mounts []v2.MountImage, targetHosts
eg, ctx := errgroup.WithContext(context.Background())
for j := range targetHosts {
node := targetHosts[j]
envs := envWrapper.Getenv(node)
envs := maps.Merge(m.Env, envGetter.Getenv(node))
cmds := formalizeImageCommands(cluster, i, m, envs)
eg.Go(func() error {
return execer.CmdAsyncWithContext(ctx, node,
Expand All @@ -69,7 +69,7 @@ func (d *Default) Apply(cluster *v2.Cluster, mounts []v2.MountImage, targetHosts
}
case m.IsApplication():
// on run on the first master
envs := envWrapper.Getenv(cluster.GetMaster0IP())
envs := maps.Merge(m.Env, envGetter.Getenv(cluster.GetMaster0IP()))
cmds := formalizeImageCommands(cluster, i, m, envs)
if err := execer.CmdAsync(cluster.GetMaster0IPAndPort(),
stringsutil.RenderShellWithEnv(strings.Join(cmds, "; "), envs),
Expand Down
2 changes: 1 addition & 1 deletion controllers/job/init/deploy/manifests/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
secretKeyRef:
name: desktop-frontend-secret
key: mongodb_uri
- name: PASSWORD_SALT_KEY
- name: PASSWORD_SALT
valueFrom:
secretKeyRef:
name: desktop-frontend-secret
Expand Down
12 changes: 12 additions & 0 deletions controllers/job/init/internal/util/common/uuid.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package common

import "github.com/google/uuid"

var adminUID string

func AdminUID() string {
if adminUID == "" {
adminUID = uuid.New().String()
}
return adminUID
}
30 changes: 25 additions & 5 deletions controllers/job/init/internal/util/controller/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package controller

import (
"context"
"time"

"github.com/labring/sealos/controllers/job/init/internal/util/common"
userv1 "github.com/labring/sealos/controllers/user/api/v1"

"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"

userv1 "github.com/labring/sealos/controllers/user/api/v1"

ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -36,14 +37,33 @@ func newKubernetesClient() (client.Client, error) {
return c, nil
}

func newAdminUser(ctx context.Context, c client.Client) (*userv1.User, error) {
var u = &userv1.User{}
u.SetName(DefaultAdminUserName)
err := c.Get(ctx, client.ObjectKeyFromObject(u), u)
if err != nil {
if client.IgnoreNotFound(err) == nil {
// admin user exists
return u, nil
}
return nil, err
}
// admin user not exists
u.SetLabels(map[string]string{"uid": common.AdminUID(), "updateTime": time.Now().Format(time.RFC3339)})
return u, nil
}

func PresetAdminUser(ctx context.Context) error {
c, err := newKubernetesClient()
if err != nil {
return err
}
_, err = ctrl.CreateOrUpdate(ctx, c, &userv1.User{ObjectMeta: ctrl.ObjectMeta{Name: DefaultAdminUserName}}, func() error { return nil })
adminUser, err := newAdminUser(ctx, c)
if err != nil {
return err
}
return nil
_, err = ctrl.CreateOrUpdate(ctx, c, adminUser, func() error {
return nil
})
return err
}
13 changes: 4 additions & 9 deletions controllers/job/init/internal/util/database/password.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@ package database

import (
"crypto/sha256"
"encoding/base64"
"encoding/hex"
"os"
)

var (
saltKey = os.Getenv("PASSWORD_SALT_KEY")
saltKey = os.Getenv("PASSWORD_SALT")
)

func hashPassword(password string) (string, error) {
func hashPassword(password string) string {
hash := sha256.New()
validSalt, err := base64.StdEncoding.DecodeString(saltKey)
if err != nil {
return "", err
}
hash.Write([]byte(password + string(validSalt)))
return hex.EncodeToString(hash.Sum(nil)), nil
hash.Write([]byte(password + saltKey))
return hex.EncodeToString(hash.Sum(nil))
}
11 changes: 3 additions & 8 deletions controllers/job/init/internal/util/database/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import (
"fmt"
"time"

"github.com/labring/sealos/controllers/job/init/internal/util/errors"

"github.com/google/uuid"
"github.com/labring/sealos/controllers/job/init/internal/util/common"
"github.com/labring/sealos/controllers/job/init/internal/util/controller"
"github.com/labring/sealos/controllers/job/init/internal/util/errors"
"github.com/labring/sealos/controllers/pkg/utils/logger"
)

Expand Down Expand Up @@ -56,11 +55,7 @@ func PresetAdminUser(ctx context.Context) error {
}

func newAdminUser() (*User, error) {
hashedPassword, err := hashPassword(DefaultAdminPassword)
if err != nil {
return nil, err
}
return newUser(uuid.New().String(), DefaultAdminUserName, DefaultAdminUserName, hashedPassword, controller.DefaultAdminUserName), nil
return newUser(common.AdminUID(), DefaultAdminUserName, DefaultAdminUserName, hashPassword(DefaultAdminPassword), controller.DefaultAdminUserName), nil
}

func newUser(uid, name, passwordUser, hashedPassword, k8sUser string) *User {
Expand Down
2 changes: 1 addition & 1 deletion deploy/cloud/scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function sealos_authorize {
# wait for admin user create
echo "Waiting for admin user create"

while [ -z "$(kubectl get ns -n ns-admin 2>/dev/null)" ]; do
while [ -z "$(kubectl get ns ns-admin 2>/dev/null)" ]; do
sleep 1
done

Expand Down
4 changes: 2 additions & 2 deletions deploy/registry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ with at least svc(s) below:
### Base applications requirements

1. At least one storage Provider, here we use aliyun OSS and CDN. Or, you can use openebs.
* `AliOSS`: read [this](https://github.com/docker/docs/blob/main/content/registry/storage-drivers/oss.md)
* `AliOSS`: read [this](https://distribution.github.io/distribution/storage-drivers/)
* `openebs` : `sealos run labring/openebs:v1.9.0`

2. One Domain name with admin access
Expand All @@ -69,7 +69,7 @@ with at least svc(s) below:

1. Example(@see [deploy.yaml](./manifests/deploy.yaml))

2. Read docker registry docs about [config](https://docs.docker.com/registry/configuration/)
2. Read docker registry docs about [config](https://distribution.github.io/distribution/about/configuration/)

3. Edit `auth`, use your own auth server.

Expand Down
Loading

0 comments on commit 110aee0

Please sign in to comment.