mirror of https://github.com/kubernetes/kops.git
Remove unnecessary data from userdata
This commit is contained in:
parent
0f36b1344e
commit
688097bd85
|
@ -27,16 +27,14 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/kops/upup/pkg/fi/cloudup/scaleway"
|
|
||||||
"k8s.io/kops/upup/pkg/fi/utils"
|
|
||||||
"sigs.k8s.io/yaml"
|
|
||||||
|
|
||||||
"k8s.io/kops/pkg/apis/kops"
|
"k8s.io/kops/pkg/apis/kops"
|
||||||
"k8s.io/kops/pkg/apis/nodeup"
|
"k8s.io/kops/pkg/apis/nodeup"
|
||||||
"k8s.io/kops/pkg/model/resources"
|
"k8s.io/kops/pkg/model/resources"
|
||||||
"k8s.io/kops/upup/pkg/fi"
|
"k8s.io/kops/upup/pkg/fi"
|
||||||
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
|
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
|
||||||
|
"k8s.io/kops/upup/pkg/fi/cloudup/scaleway"
|
||||||
"k8s.io/kops/upup/pkg/fi/fitasks"
|
"k8s.io/kops/upup/pkg/fi/fitasks"
|
||||||
|
"k8s.io/kops/upup/pkg/fi/utils"
|
||||||
"k8s.io/kops/util/pkg/architectures"
|
"k8s.io/kops/util/pkg/architectures"
|
||||||
"k8s.io/kops/util/pkg/mirrors"
|
"k8s.io/kops/util/pkg/mirrors"
|
||||||
)
|
)
|
||||||
|
@ -341,49 +339,6 @@ func (b *BootstrapScript) Run(c *fi.CloudupContext) error {
|
||||||
nodeupScript.ProxyEnv = func() (string, error) {
|
nodeupScript.ProxyEnv = func() (string, error) {
|
||||||
return b.createProxyEnv(c.T.Cluster.Spec.Networking.EgressProxy)
|
return b.createProxyEnv(c.T.Cluster.Spec.Networking.EgressProxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeupScript.ClusterSpec = func() (string, error) {
|
|
||||||
cs := c.T.Cluster.Spec
|
|
||||||
|
|
||||||
spec := make(map[string]interface{})
|
|
||||||
spec["cloudConfig"] = cs.CloudConfig
|
|
||||||
spec["kubelet"] = cs.Kubelet
|
|
||||||
|
|
||||||
if b.ig.IsControlPlane() {
|
|
||||||
spec["encryptionConfig"] = cs.EncryptionConfig
|
|
||||||
spec["etcdClusters"] = make(map[string]kops.EtcdClusterSpec)
|
|
||||||
spec["kubeAPIServer"] = cs.KubeAPIServer
|
|
||||||
spec["kubeControllerManager"] = cs.KubeControllerManager
|
|
||||||
spec["kubeScheduler"] = cs.KubeScheduler
|
|
||||||
spec["masterKubelet"] = cs.ControlPlaneKubelet
|
|
||||||
|
|
||||||
for _, etcdCluster := range cs.EtcdClusters {
|
|
||||||
c := kops.EtcdClusterSpec{
|
|
||||||
Image: etcdCluster.Image,
|
|
||||||
Version: etcdCluster.Version,
|
|
||||||
Manager: etcdCluster.Manager,
|
|
||||||
CPURequest: etcdCluster.CPURequest,
|
|
||||||
MemoryRequest: etcdCluster.MemoryRequest,
|
|
||||||
}
|
|
||||||
for _, etcdMember := range etcdCluster.Members {
|
|
||||||
if fi.ValueOf(etcdMember.InstanceGroup) == b.ig.Name && etcdMember.VolumeSize != nil {
|
|
||||||
m := kops.EtcdMemberSpec{
|
|
||||||
Name: etcdMember.Name,
|
|
||||||
VolumeSize: etcdMember.VolumeSize,
|
|
||||||
}
|
|
||||||
c.Members = append(c.Members, m)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
spec["etcdClusters"].(map[string]kops.EtcdClusterSpec)[etcdCluster.Name] = c
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
content, err := yaml.Marshal(spec)
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("error converting cluster spec to yaml for inclusion within bootstrap script: %v", err)
|
|
||||||
}
|
|
||||||
return string(content), nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeupScript.CompressUserData = fi.ValueOf(b.ig.Spec.CompressUserData)
|
nodeupScript.CompressUserData = fi.ValueOf(b.ig.Spec.CompressUserData)
|
||||||
|
|
|
@ -160,14 +160,6 @@ function download-release() {
|
||||||
echo "== nodeup node config starting =="
|
echo "== nodeup node config starting =="
|
||||||
ensure-install-dir
|
ensure-install-dir
|
||||||
|
|
||||||
{{ if CompressUserData -}}
|
|
||||||
echo "{{ GzipBase64 ClusterSpec }}" | base64 -d | gzip -d > conf/cluster_spec.yaml
|
|
||||||
{{- else -}}
|
|
||||||
cat > conf/cluster_spec.yaml << '__EOF_CLUSTER_SPEC'
|
|
||||||
{{ ClusterSpec }}
|
|
||||||
__EOF_CLUSTER_SPEC
|
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
{{ if CompressUserData -}}
|
{{ if CompressUserData -}}
|
||||||
echo "{{ GzipBase64 KubeEnv }}" | base64 -d | gzip -d > conf/kube_env.yaml
|
echo "{{ GzipBase64 KubeEnv }}" | base64 -d | gzip -d > conf/kube_env.yaml
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
|
@ -189,7 +181,6 @@ type NodeUpScript struct {
|
||||||
CloudProvider string
|
CloudProvider string
|
||||||
ProxyEnv func() (string, error)
|
ProxyEnv func() (string, error)
|
||||||
EnvironmentVariables func() (string, error)
|
EnvironmentVariables func() (string, error)
|
||||||
ClusterSpec func() (string, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func funcEmptyString() (string, error) {
|
func funcEmptyString() (string, error) {
|
||||||
|
@ -203,9 +194,6 @@ func (b *NodeUpScript) Build() (fi.Resource, error) {
|
||||||
if b.EnvironmentVariables == nil {
|
if b.EnvironmentVariables == nil {
|
||||||
b.EnvironmentVariables = funcEmptyString
|
b.EnvironmentVariables = funcEmptyString
|
||||||
}
|
}
|
||||||
if b.ClusterSpec == nil {
|
|
||||||
b.ClusterSpec = funcEmptyString
|
|
||||||
}
|
|
||||||
|
|
||||||
functions := template.FuncMap{
|
functions := template.FuncMap{
|
||||||
"NodeUpSourceAmd64": func() string {
|
"NodeUpSourceAmd64": func() string {
|
||||||
|
@ -260,7 +248,6 @@ func (b *NodeUpScript) Build() (fi.Resource, error) {
|
||||||
|
|
||||||
"ProxyEnv": b.ProxyEnv,
|
"ProxyEnv": b.ProxyEnv,
|
||||||
"EnvironmentVariables": b.EnvironmentVariables,
|
"EnvironmentVariables": b.EnvironmentVariables,
|
||||||
"ClusterSpec": b.ClusterSpec,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return newTemplateResource("nodeup", nodeUpTemplate, functions, nil)
|
return newTemplateResource("nodeup", nodeUpTemplate, functions, nil)
|
||||||
|
|
Loading…
Reference in New Issue