fix: configure cilium for talos
This commit is contained in:
parent
cc52263625
commit
5ffe62c5c7
|
|
@ -41,10 +41,16 @@ func (r Runner) Run() error {
|
||||||
func(dir string) error { return ghrepo.WriteManifestsStructure(dir, r.Config.Flux.ManifestsRepo) },
|
func(dir string) error { return ghrepo.WriteManifestsStructure(dir, r.Config.Flux.ManifestsRepo) },
|
||||||
func(dir string) error {
|
func(dir string) error {
|
||||||
clusterDir := filepath.Join(dir, strings.TrimPrefix(r.Config.Flux.ClusterPath, "./"))
|
clusterDir := filepath.Join(dir, strings.TrimPrefix(r.Config.Flux.ClusterPath, "./"))
|
||||||
if err := copyDir(filepath.Join(cicdTemplateDir, "base"), filepath.Join(dir, "base")); err != nil {
|
if err := copyDir(filepath.Join(cicdTemplateDir, "base"), filepath.Join(dir, "base"), false); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := copyDir(filepath.Join(cicdTemplateDir, "clusters", "template"), clusterDir); err != nil {
|
if err := copyDir(filepath.Join(cicdTemplateDir, "clusters", "template"), clusterDir, false); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := copyDir(filepath.Join(cicdTemplateDir, "base", "cilium"), filepath.Join(dir, "base", "cilium"), true); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := copyDir(filepath.Join(cicdTemplateDir, "base", "cilium-config"), filepath.Join(dir, "base", "cilium-config"), true); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := renderCiliumConfig(filepath.Join(dir, "base", "cilium"), r.Config); err != nil {
|
if err := renderCiliumConfig(filepath.Join(dir, "base", "cilium"), r.Config); err != nil {
|
||||||
|
|
@ -162,10 +168,10 @@ func installCilium(dir string, cfg config.Config) error {
|
||||||
if err := os.MkdirAll(helmDir, 0755); err != nil {
|
if err := os.MkdirAll(helmDir, 0755); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return utils.RunCommandInDir(dir, "helm", "upgrade", "--install", "cilium", "cilium", "--repo=https://helm.cilium.io", "--version=1.19.6", "--repository-config="+filepath.Join(helmDir, "repositories.yaml"), "--repository-cache="+helmDir, "--namespace=kube-system", "--create-namespace", "--kubeconfig=kubeconfig", "--wait", "--timeout=5m", "--set=kubeProxyReplacement=true", "--set=ipam.mode=kubernetes", "--set=k8sServiceHost="+cfg.Talos.KubeconfigEndpoint, "--set=k8sServicePort=6443", "--set=gatewayAPI.enabled=true", "--set=l2announcements.enabled=true")
|
return utils.RunCommandInDir(dir, "helm", "upgrade", "--install", "cilium", "cilium", "--repo=https://helm.cilium.io", "--version=1.19.6", "--repository-config="+filepath.Join(helmDir, "repositories.yaml"), "--repository-cache="+helmDir, "--namespace=kube-system", "--create-namespace", "--kubeconfig=kubeconfig", "--wait", "--timeout=5m", "--set=kubeProxyReplacement=true", "--set=ipam.mode=kubernetes", "--set=k8sServiceHost=localhost", "--set=k8sServicePort=7445", "--set=cgroup.autoMount.enabled=false", "--set=cgroup.hostRoot=/sys/fs/cgroup", "--set=bpf.hostLegacyRouting=true", "--set=securityContext.capabilities.ciliumAgent={CHOWN,KILL,NET_ADMIN,NET_RAW,IPC_LOCK,SYS_ADMIN,SYS_RESOURCE,DAC_OVERRIDE,FOWNER,SETGID,SETUID}", "--set=securityContext.capabilities.cleanCiliumState={NET_ADMIN,SYS_ADMIN,SYS_RESOURCE}", "--set=gatewayAPI.enabled=true", "--set=l2announcements.enabled=true")
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyDir(source, destination string) error {
|
func copyDir(source, destination string, overwrite bool) error {
|
||||||
return filepath.Walk(source, func(path string, info os.FileInfo, err error) error {
|
return filepath.Walk(source, func(path string, info os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -178,7 +184,7 @@ func copyDir(source, destination string) error {
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
return os.MkdirAll(target, 0755)
|
return os.MkdirAll(target, 0755)
|
||||||
}
|
}
|
||||||
if _, err := os.Stat(target); err == nil {
|
if _, err := os.Stat(target); err == nil && !overwrite {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
input, err := os.Open(path)
|
input, err := os.Open(path)
|
||||||
|
|
@ -186,7 +192,11 @@ func copyDir(source, destination string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer input.Close()
|
defer input.Close()
|
||||||
output, err := os.OpenFile(target, os.O_WRONLY|os.O_CREATE|os.O_EXCL, info.Mode())
|
flags := os.O_WRONLY | os.O_CREATE | os.O_EXCL
|
||||||
|
if overwrite {
|
||||||
|
flags = os.O_WRONLY | os.O_CREATE | os.O_TRUNC
|
||||||
|
}
|
||||||
|
output, err := os.OpenFile(target, flags, info.Mode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue