mirror of
https://github.com/openshift/installer.git
synced 2026-02-06 00:48:45 +01:00
manifests: stop using kube core operator
In order to switch to OpenShift operators and bootstrap we need to remove the kube-core-operator rendering and not rely on the assets provided by this operator. The new assets are provided by kube/openshift operator renderers.
This commit is contained in:
@@ -74,7 +74,6 @@ func (a *Bootstrap) Dependencies() []asset.Asset {
|
||||
&kubeconfig.Kubelet{},
|
||||
&manifests.Manifests{},
|
||||
&manifests.Tectonic{},
|
||||
&manifests.KubeCoreOperator{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,18 +169,13 @@ func (a *Bootstrap) getTemplateData(installConfig *types.InstallConfig) (*bootst
|
||||
|
||||
func (a *Bootstrap) addBootstrapFiles(dependencies asset.Parents) {
|
||||
kubeletKubeconfig := &kubeconfig.Kubelet{}
|
||||
kubeCoreOperator := &manifests.KubeCoreOperator{}
|
||||
dependencies.Get(kubeletKubeconfig, kubeCoreOperator)
|
||||
dependencies.Get(kubeletKubeconfig)
|
||||
|
||||
a.Config.Storage.Files = append(
|
||||
a.Config.Storage.Files,
|
||||
ignition.FileFromBytes("/etc/kubernetes/kubeconfig", 0600, kubeletKubeconfig.Files()[0].Data),
|
||||
ignition.FileFromBytes("/var/lib/kubelet/kubeconfig", 0600, kubeletKubeconfig.Files()[0].Data),
|
||||
)
|
||||
a.Config.Storage.Files = append(
|
||||
a.Config.Storage.Files,
|
||||
ignition.FilesFromAsset(rootDir, 0644, kubeCoreOperator)...,
|
||||
)
|
||||
a.Config.Storage.Files = append(
|
||||
a.Config.Storage.Files,
|
||||
ignition.FileFromString("/opt/tectonic/report-progress.sh", 0555, content.ReportShFileContents),
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package tectonic
|
||||
|
||||
const (
|
||||
// AppVersionKubeCore is the variable/constant representing the contents of the respective file
|
||||
AppVersionKubeCore = `
|
||||
---
|
||||
apiVersion: tco.coreos.com/v1
|
||||
kind: AppVersion
|
||||
metadata:
|
||||
name: kube-core
|
||||
namespace: tectonic-system
|
||||
labels:
|
||||
managed-by-channel-operator: "true"
|
||||
spec:
|
||||
paused: false
|
||||
status:
|
||||
paused: false
|
||||
upgradereq: 0
|
||||
upgradecomp: 0
|
||||
`
|
||||
)
|
||||
@@ -1,65 +0,0 @@
|
||||
package tectonic
|
||||
|
||||
import (
|
||||
"text/template"
|
||||
)
|
||||
|
||||
var (
|
||||
// KubeCoreOperator is the variable/constant representing the contents of the respective file
|
||||
KubeCoreOperator = template.Must(template.New("kube-core-00-operator.yaml").Parse(`
|
||||
apiVersion: apps/v1beta2
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: kube-core-operator
|
||||
namespace: kube-system
|
||||
labels:
|
||||
k8s-app: kube-core-operator
|
||||
managed-by-channel-operator: "true"
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
k8s-app: kube-core-operator
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kube-core-operator
|
||||
tectonic-app-version-name: kube-core
|
||||
spec:
|
||||
containers:
|
||||
- name: kube-core-operator
|
||||
image: {{.KubeCoreOperatorImage}}
|
||||
imagePullPolicy: Always
|
||||
args:
|
||||
- --config=/etc/cluster-config/kco-config.yaml
|
||||
resources:
|
||||
limits:
|
||||
cpu: 20m
|
||||
memory: 50Mi
|
||||
requests:
|
||||
cpu: 20m
|
||||
memory: 50Mi
|
||||
volumeMounts:
|
||||
- name: cluster-config
|
||||
mountPath: /etc/cluster-config
|
||||
imagePullSecrets:
|
||||
- name: coreos-pull-secret
|
||||
nodeSelector:
|
||||
node-role.kubernetes.io/master: ""
|
||||
restartPolicy: Always
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 65534
|
||||
tolerations:
|
||||
- key: "node-role.kubernetes.io/master"
|
||||
operator: "Exists"
|
||||
effect: "NoSchedule"
|
||||
volumes:
|
||||
- name: cluster-config
|
||||
configMap:
|
||||
name: cluster-config-v1
|
||||
items:
|
||||
- key: kco-config
|
||||
path: kco-config.yaml
|
||||
`))
|
||||
)
|
||||
@@ -1,133 +0,0 @@
|
||||
package manifests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/apparentlymart/go-cidr/cidr"
|
||||
kubecore "github.com/coreos/tectonic-config/config/kube-core"
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/openshift/installer/pkg/asset"
|
||||
"github.com/openshift/installer/pkg/asset/installconfig"
|
||||
"github.com/openshift/installer/pkg/types"
|
||||
)
|
||||
|
||||
const (
|
||||
authConfigOIDCClientID = "tectonic-kubectl"
|
||||
authConfigOIDCGroupsClaim = "groups"
|
||||
authConfigOIDCUsernameClaim = "email"
|
||||
networkConfigAdvertiseAddress = "0.0.0.0"
|
||||
)
|
||||
|
||||
// KubeCoreOperator generates the kube-core-operator.yaml files
|
||||
type KubeCoreOperator struct {
|
||||
Config *kubecore.OperatorConfig
|
||||
File *asset.File
|
||||
}
|
||||
|
||||
var _ asset.WritableAsset = (*KubeCoreOperator)(nil)
|
||||
|
||||
// Name returns a human friendly name for the operator
|
||||
func (kco *KubeCoreOperator) Name() string {
|
||||
return "Kube Core Operator"
|
||||
}
|
||||
|
||||
// Dependencies returns all of the dependencies directly needed by an
|
||||
// KubeCoreOperator asset.
|
||||
func (kco *KubeCoreOperator) Dependencies() []asset.Asset {
|
||||
return []asset.Asset{
|
||||
&installconfig.InstallConfig{},
|
||||
}
|
||||
}
|
||||
|
||||
// Generate generates the kube-core-operator-config.yml files
|
||||
func (kco *KubeCoreOperator) Generate(dependencies asset.Parents) error {
|
||||
installConfig := &installconfig.InstallConfig{}
|
||||
dependencies.Get(installConfig)
|
||||
|
||||
clusterIP, err := cidr.Host(&installConfig.Config.Networking.ServiceCIDR.IPNet, 10)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create %s config from InstallConfig", kco.Name())
|
||||
}
|
||||
|
||||
kco.Config = &kubecore.OperatorConfig{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: kubecore.APIVersion,
|
||||
Kind: kubecore.Kind,
|
||||
},
|
||||
ClusterConfig: kubecore.ClusterConfig{
|
||||
APIServerURL: getAPIServerURL(installConfig.Config),
|
||||
},
|
||||
AuthConfig: kubecore.AuthConfig{
|
||||
OIDCClientID: authConfigOIDCClientID,
|
||||
OIDCIssuerURL: getOicdIssuerURL(installConfig.Config),
|
||||
OIDCGroupsClaim: authConfigOIDCGroupsClaim,
|
||||
OIDCUsernameClaim: authConfigOIDCUsernameClaim,
|
||||
},
|
||||
DNSConfig: kubecore.DNSConfig{
|
||||
ClusterIP: clusterIP.String(),
|
||||
},
|
||||
CloudProviderConfig: kubecore.CloudProviderConfig{
|
||||
CloudConfigPath: "",
|
||||
CloudProviderProfile: k8sCloudProvider(installConfig.Config.Platform),
|
||||
},
|
||||
RoutingConfig: kubecore.RoutingConfig{
|
||||
Subdomain: getBaseAddress(installConfig.Config),
|
||||
},
|
||||
NetworkConfig: kubecore.NetworkConfig{
|
||||
ClusterCIDR: installConfig.Config.Networking.PodCIDR.String(),
|
||||
ServiceCIDR: installConfig.Config.Networking.ServiceCIDR.String(),
|
||||
AdvertiseAddress: networkConfigAdvertiseAddress,
|
||||
EtcdServers: strings.Join(getEtcdServersURLs(installConfig.Config), ","),
|
||||
},
|
||||
}
|
||||
|
||||
data, err := yaml.Marshal(kco.Config)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create %s config from InstallConfig", kco.Name())
|
||||
}
|
||||
kco.File = &asset.File{
|
||||
Filename: "kco-config.yaml",
|
||||
Data: data,
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Files returns the files generated by the asset.
|
||||
func (kco *KubeCoreOperator) Files() []*asset.File {
|
||||
if kco.File != nil {
|
||||
return []*asset.File{kco.File}
|
||||
}
|
||||
return []*asset.File{}
|
||||
}
|
||||
|
||||
func getEtcdServersURLs(ic *types.InstallConfig) []string {
|
||||
var urls []string
|
||||
for i := 0; i < ic.MasterCount(); i++ {
|
||||
urls = append(urls, fmt.Sprintf("https://%s-etcd-%d.%s:2379", ic.ObjectMeta.Name, i, ic.BaseDomain))
|
||||
}
|
||||
return urls
|
||||
}
|
||||
|
||||
func getOicdIssuerURL(ic *types.InstallConfig) string {
|
||||
return fmt.Sprintf("https://%s.%s/identity", ic.ObjectMeta.Name, ic.BaseDomain)
|
||||
}
|
||||
|
||||
func getBaseAddress(ic *types.InstallConfig) string {
|
||||
return fmt.Sprintf("%s.%s", ic.ObjectMeta.Name, ic.BaseDomain)
|
||||
}
|
||||
|
||||
// Converts a platform to the cloudProvider that k8s understands
|
||||
func k8sCloudProvider(platform types.Platform) string {
|
||||
if platform.AWS != nil {
|
||||
return "aws"
|
||||
}
|
||||
if platform.Libvirt != nil {
|
||||
//return "libvirt"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -44,7 +44,6 @@ func (m *Manifests) Name() string {
|
||||
func (m *Manifests) Dependencies() []asset.Asset {
|
||||
return []asset.Asset{
|
||||
&installconfig.InstallConfig{},
|
||||
&KubeCoreOperator{},
|
||||
&networkOperator{},
|
||||
&kubeAddonOperator{},
|
||||
&machineAPIOperator{},
|
||||
@@ -70,16 +69,14 @@ func (m *Manifests) Dependencies() []asset.Asset {
|
||||
|
||||
// Generate generates the respective operator config.yml files
|
||||
func (m *Manifests) Generate(dependencies asset.Parents) error {
|
||||
kco := &KubeCoreOperator{}
|
||||
no := &networkOperator{}
|
||||
addon := &kubeAddonOperator{}
|
||||
mao := &machineAPIOperator{}
|
||||
installConfig := &installconfig.InstallConfig{}
|
||||
dependencies.Get(kco, no, addon, mao, installConfig)
|
||||
dependencies.Get(no, addon, mao, installConfig)
|
||||
|
||||
// kco+no+mao go to kube-system config map
|
||||
// no+mao go to kube-system config map
|
||||
m.KubeSysConfig = configMap("kube-system", "cluster-config-v1", genericData{
|
||||
"kco-config": string(kco.Files()[0].Data),
|
||||
"network-config": string(no.Files()[0].Data),
|
||||
"install-config": string(installConfig.Files()[0].Data),
|
||||
"mao-config": string(mao.Files()[0].Data),
|
||||
|
||||
@@ -63,8 +63,6 @@ func (t *Tectonic) Generate(dependencies asset.Parents) error {
|
||||
"99_binding-discovery.yaml": []byte(content.BindingDiscovery),
|
||||
"99_kube-addon-00-appversion.yaml": []byte(content.AppVersionKubeAddon),
|
||||
"99_kube-addon-01-operator.yaml": applyTemplateData(content.KubeAddonOperator, templateData),
|
||||
"99_kube-core-00-appversion.yaml": []byte(content.AppVersionKubeCore),
|
||||
"99_kube-core-00-operator.yaml": applyTemplateData(content.KubeCoreOperator, templateData),
|
||||
"99_openshift-cluster-api_cluster.yaml": clusterk8sio.Raw,
|
||||
"99_openshift-cluster-api_worker-machineset.yaml": worker.MachineSetRaw,
|
||||
"99_openshift-cluster-api_worker-user-data-secret.yaml": worker.UserDataSecretRaw,
|
||||
|
||||
Reference in New Issue
Block a user