mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Package static assets
Include static Helm assets in the build process needed for air-gap
This commit is contained in:
parent
5716acab44
commit
ffcc9c0c9c
1
main.go
1
main.go
@ -1,6 +1,7 @@
|
||||
//go:generate go run types/codegen/cleanup/main.go
|
||||
//go:generate go run types/codegen/main.go
|
||||
//go:generate go fmt pkg/deploy/zz_generated_bindata.go
|
||||
//go:generate go fmt pkg/static/zz_generated_bindata.go
|
||||
//go:generate go fmt pkg/openapi/zz_generated_bindata.go
|
||||
|
||||
package main
|
||||
|
@ -19,11 +19,12 @@ import (
|
||||
"github.com/rancher/k3s/pkg/deploy"
|
||||
"github.com/rancher/k3s/pkg/helm"
|
||||
"github.com/rancher/k3s/pkg/servicelb"
|
||||
"github.com/rancher/k3s/pkg/static"
|
||||
"github.com/rancher/k3s/pkg/tls"
|
||||
appsv1 "github.com/rancher/k3s/types/apis/apps/v1"
|
||||
batchv1 "github.com/rancher/k3s/types/apis/batch/v1"
|
||||
corev1 "github.com/rancher/k3s/types/apis/core/v1"
|
||||
"github.com/rancher/k3s/types/apis/k3s.cattle.io/v1"
|
||||
v1 "github.com/rancher/k3s/types/apis/k3s.cattle.io/v1"
|
||||
rbacv1 "github.com/rancher/k3s/types/apis/rbac.authorization.k8s.io/v1"
|
||||
"github.com/rancher/norman"
|
||||
"github.com/rancher/norman/pkg/clientaccess"
|
||||
@ -118,6 +119,10 @@ func startNorman(ctx context.Context, config *Config) (string, error) {
|
||||
func(ctx context.Context) error {
|
||||
return servicelb.Register(ctx, norman.GetServer(ctx).K8sClient, !config.DisableServiceLB)
|
||||
},
|
||||
func(ctx context.Context) error {
|
||||
dataDir := filepath.Join(controlConfig.DataDir, "static")
|
||||
return static.Stage(dataDir)
|
||||
},
|
||||
func(ctx context.Context) error {
|
||||
dataDir := filepath.Join(controlConfig.DataDir, "manifests")
|
||||
templateVars := map[string]string{"%{CLUSTER_DNS}%": controlConfig.ClusterDNS.String()}
|
||||
|
27
pkg/static/stage.go
Normal file
27
pkg/static/stage.go
Normal file
@ -0,0 +1,27 @@
|
||||
package static
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func Stage(dataDir string) error {
|
||||
for _, name := range AssetNames() {
|
||||
content, err := Asset(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p := filepath.Join(dataDir, name)
|
||||
logrus.Info("Writing static file: ", p)
|
||||
os.MkdirAll(filepath.Dir(p), 0700)
|
||||
if err := ioutil.WriteFile(p, content, 0600); err != nil {
|
||||
return errors.Wrapf(err, "failed to write to %s", name)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -1,10 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
ROOT_VERSION=v0.0.1
|
||||
|
||||
source $(dirname $0)/version.sh
|
||||
|
||||
cd $(dirname $0)/..
|
||||
|
||||
ROOT_VERSION=v0.0.1
|
||||
TRAEFIK_VERSION=1.64.0
|
||||
CHARTS_DIR=build/static/charts
|
||||
|
||||
mkdir -p ${CHARTS_DIR}
|
||||
|
||||
curl --compressed -sfL https://github.com/ibuildthecloud/k3s-root/releases/download/${ROOT_VERSION}/k3s-root-${ARCH}.tar | tar xf -
|
||||
ln -sf pigz bin/unpigz
|
||||
|
||||
TRAEFIK_FILE=traefik-${TRAEFIK_VERSION}.tgz
|
||||
curl -sfL https://kubernetes-charts.storage.googleapis.com/${TRAEFIK_FILE} -o ${CHARTS_DIR}/${TRAEFIK_FILE}
|
||||
|
@ -48,6 +48,22 @@ func main() {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
bc = &bindata.Config{
|
||||
Input: []bindata.InputConfig{
|
||||
{
|
||||
Path: "build/static",
|
||||
Recursive: true,
|
||||
},
|
||||
},
|
||||
Package: "static",
|
||||
NoMetadata: true,
|
||||
Prefix: "build/static/",
|
||||
Output: "pkg/static/zz_generated_bindata.go",
|
||||
}
|
||||
if err := bindata.Translate(bc); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
bc = &bindata.Config{
|
||||
Input: []bindata.InputConfig{
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user