From 166a9f1eb344984318fb4d2bcba2db7e343cc358 Mon Sep 17 00:00:00 2001 From: Rajat Chopra Date: Tue, 30 Oct 2018 23:23:57 -0400 Subject: [PATCH] pkg/asset: new target manifest-templates 1. Move files from manifests/content to templates directory 2. Create new asset called templates that the target manifest-templates can directly call 3. All template files are separate assets by themselves, and 'templates' asset depends on all leaf template assets 4. Manifest/tectonic assets now use templates as parent assets that they depend upon Other templates (e.g. ignition/machines) are not moved into assets in this commit. data/data/manifests: move all yaml content to its own files So that a yaml lint check can catch the inappropriate ones. No functional change at runtime. --- cmd/openshift-install/create.go | 13 +- .../bootkube/01-tectonic-namespace.yaml | 8 - .../03-openshift-web-console-namespace.yaml | 8 - .../04-openshift-machine-config-operator.yaml | 7 + .../05-openshift-cluster-api-namespace.yaml | 8 - ...enshift-service-cert-signer-namespace.yaml | 7 + .../manifests/bootkube/app-version-kind.yaml | 8 - .../app-version-tectonic-network.yaml | 8 - .../bootkube/cvo-overrides.yaml.template | 17 ++ .../etcd-service-endpoints.yaml.template | 17 ++ .../data/manifests/bootkube/etcd-service.yaml | 8 - .../manifests/bootkube/kube-cloud-config.yaml | 8 + ...em-configmap-etcd-serving-ca.yaml.template | 8 + ...ube-system-configmap-root-ca.yaml.template | 7 + ...be-system-secret-etcd-client.yaml.template | 9 + .../legacy-cvo-overrides.yaml.template | 16 ++ ...ine-config-server-tls-secret.yaml.template | 9 + ...ervice-cert-signer-ca-secret.yaml.template | 9 + .../manifests/bootkube/pull.yaml.template | 11 -- .../tectonic-network-operator.yaml.template | 12 -- .../manifests/tectonic/binding-discovery.yaml | 13 ++ .../tectonic/cloud-creds-secret.yaml.template | 12 -- .../tectonic/kube-addon-00-appversion.yaml | 8 - .../kube-addon-01-operator.yaml.template | 12 -- data/data/manifests/tectonic/role-admin.yaml | 10 ++ ...le-cloud-creds-secret-reader.yaml.template | 12 -- data/data/manifests/tectonic/role-user.yaml | 67 ++++++++ .../tectonic-system-00-binding-admin.yaml | 15 ++ .../tectonic-system-02-pull.yaml.template | 12 ++ .../04-openshift-machine-config-operator.go | 14 -- ...openshift-service-cert-signer-namespace.go | 15 -- .../content/bootkube/cvo-overrides.go | 55 ------ .../bootkube/etcd-service-endpoints.go | 34 ---- .../content/bootkube/kube-cloud-config.go | 19 --- .../kube-system-configmap-etcd-serving-ca.go | 18 -- .../bootkube/kube-system-configmap-root-ca.go | 17 -- .../kube-system-secret-etcd-client.go | 20 --- .../machine-config-server-tls-secret.go | 20 --- ...openshift-service-cert-signer-ca-secret.go | 20 --- .../content/tectonic/binding-discovery.go | 21 --- .../manifests/content/tectonic/role-admin.go | 18 -- .../manifests/content/tectonic/role-user.go | 75 -------- .../tectonic-system-00-binding-admin.go | 23 --- .../tectonic/tectonic-system-02-pull.go | 23 --- pkg/asset/manifests/operators.go | 113 +++++++++--- pkg/asset/manifests/tectonic.go | 49 ++++-- .../content/bootkube/01-tectonic-namespace.go | 66 +++++++ .../03-openshift-web-console-namespace.go | 65 +++++++ .../04-openshift-machine-config-operator.go | 65 +++++++ .../05-openshift-cluster-api-namespace.go | 65 +++++++ ...openshift-service-cert-signer-namespace.go | 65 +++++++ .../content/bootkube/app-version-kind.go | 65 +++++++ .../bootkube/app-version-tectonic-network.go | 65 +++++++ .../content/bootkube/cvo-overrides.go | 68 ++++++++ .../bootkube/etcd-service-endpoints.go | 65 +++++++ .../content/bootkube/etcd-service.go | 65 +++++++ .../content/bootkube/kube-cloud-config.go | 65 +++++++ .../kube-system-configmap-etcd-serving-ca.go | 65 +++++++ .../bootkube/kube-system-configmap-root-ca.go | 65 +++++++ .../kube-system-secret-etcd-client.go | 65 +++++++ .../content/bootkube/legacy-cvo-overrides.go | 68 ++++++++ .../machine-config-server-tls-secret.go | 65 +++++++ ...openshift-service-cert-signer-ca-secret.go | 65 +++++++ pkg/asset/templates/content/bootkube/pull.go | 65 +++++++ .../bootkube/tectonic-network-operator.go | 65 +++++++ pkg/asset/templates/content/helper.go | 36 ++++ .../content/tectonic/binding-discovery.go | 65 +++++++ .../content/tectonic/cloud-creds-secret.go | 65 +++++++ .../tectonic/kube-addon-00-appversion.go | 65 +++++++ .../tectonic/kube-addon-01-operator.go | 65 +++++++ .../templates/content/tectonic/role-admin.go | 65 +++++++ .../role-cloud-creds-secret-reader.go | 65 +++++++ .../templates/content/tectonic/role-user.go | 65 +++++++ .../tectonic-system-00-binding-admin.go | 65 +++++++ .../tectonic/tectonic-system-02-pull.go | 65 +++++++ pkg/asset/templates/templates.go | 161 ++++++++++++++++++ 76 files changed, 2397 insertions(+), 540 deletions(-) rename pkg/asset/manifests/content/bootkube/01-tectonic-namespace.go => data/data/manifests/bootkube/01-tectonic-namespace.yaml (58%) rename pkg/asset/manifests/content/bootkube/03-openshift-web-console-namespace.go => data/data/manifests/bootkube/03-openshift-web-console-namespace.yaml (56%) create mode 100644 data/data/manifests/bootkube/04-openshift-machine-config-operator.yaml rename pkg/asset/manifests/content/bootkube/05-openshift-cluster-api-namespace.go => data/data/manifests/bootkube/05-openshift-cluster-api-namespace.yaml (53%) create mode 100644 data/data/manifests/bootkube/09-openshift-service-cert-signer-namespace.yaml rename pkg/asset/manifests/content/bootkube/app-version-kind.go => data/data/manifests/bootkube/app-version-kind.yaml (62%) rename pkg/asset/manifests/content/bootkube/app-version-tectonic-network.go => data/data/manifests/bootkube/app-version-tectonic-network.yaml (60%) create mode 100644 data/data/manifests/bootkube/cvo-overrides.yaml.template create mode 100644 data/data/manifests/bootkube/etcd-service-endpoints.yaml.template rename pkg/asset/manifests/content/bootkube/etcd-service.go => data/data/manifests/bootkube/etcd-service.yaml (63%) create mode 100644 data/data/manifests/bootkube/kube-cloud-config.yaml create mode 100644 data/data/manifests/bootkube/kube-system-configmap-etcd-serving-ca.yaml.template create mode 100644 data/data/manifests/bootkube/kube-system-configmap-root-ca.yaml.template create mode 100644 data/data/manifests/bootkube/kube-system-secret-etcd-client.yaml.template create mode 100644 data/data/manifests/bootkube/legacy-cvo-overrides.yaml.template create mode 100644 data/data/manifests/bootkube/machine-config-server-tls-secret.yaml.template create mode 100644 data/data/manifests/bootkube/openshift-service-cert-signer-ca-secret.yaml.template rename pkg/asset/manifests/content/bootkube/pull.go => data/data/manifests/bootkube/pull.yaml.template (56%) rename pkg/asset/manifests/content/bootkube/tectonic-network-operator.go => data/data/manifests/bootkube/tectonic-network-operator.yaml.template (85%) create mode 100644 data/data/manifests/tectonic/binding-discovery.yaml rename pkg/asset/manifests/content/tectonic/cloud-creds-secret.go => data/data/manifests/tectonic/cloud-creds-secret.yaml.template (66%) rename pkg/asset/manifests/content/tectonic/kube-addon-00-appversion.go => data/data/manifests/tectonic/kube-addon-00-appversion.yaml (62%) rename pkg/asset/manifests/content/tectonic/kube-addon-01-operator.go => data/data/manifests/tectonic/kube-addon-01-operator.yaml.template (84%) create mode 100644 data/data/manifests/tectonic/role-admin.yaml rename pkg/asset/manifests/content/tectonic/role-cloud-creds-secret-reader.go => data/data/manifests/tectonic/role-cloud-creds-secret-reader.yaml.template (62%) create mode 100644 data/data/manifests/tectonic/role-user.yaml create mode 100644 data/data/manifests/tectonic/tectonic-system-00-binding-admin.yaml create mode 100644 data/data/manifests/tectonic/tectonic-system-02-pull.yaml.template delete mode 100644 pkg/asset/manifests/content/bootkube/04-openshift-machine-config-operator.go delete mode 100644 pkg/asset/manifests/content/bootkube/09-openshift-service-cert-signer-namespace.go delete mode 100644 pkg/asset/manifests/content/bootkube/cvo-overrides.go delete mode 100644 pkg/asset/manifests/content/bootkube/etcd-service-endpoints.go delete mode 100644 pkg/asset/manifests/content/bootkube/kube-cloud-config.go delete mode 100644 pkg/asset/manifests/content/bootkube/kube-system-configmap-etcd-serving-ca.go delete mode 100644 pkg/asset/manifests/content/bootkube/kube-system-configmap-root-ca.go delete mode 100644 pkg/asset/manifests/content/bootkube/kube-system-secret-etcd-client.go delete mode 100644 pkg/asset/manifests/content/bootkube/machine-config-server-tls-secret.go delete mode 100644 pkg/asset/manifests/content/bootkube/openshift-service-cert-signer-ca-secret.go delete mode 100644 pkg/asset/manifests/content/tectonic/binding-discovery.go delete mode 100644 pkg/asset/manifests/content/tectonic/role-admin.go delete mode 100644 pkg/asset/manifests/content/tectonic/role-user.go delete mode 100644 pkg/asset/manifests/content/tectonic/tectonic-system-00-binding-admin.go delete mode 100644 pkg/asset/manifests/content/tectonic/tectonic-system-02-pull.go create mode 100644 pkg/asset/templates/content/bootkube/01-tectonic-namespace.go create mode 100644 pkg/asset/templates/content/bootkube/03-openshift-web-console-namespace.go create mode 100644 pkg/asset/templates/content/bootkube/04-openshift-machine-config-operator.go create mode 100644 pkg/asset/templates/content/bootkube/05-openshift-cluster-api-namespace.go create mode 100644 pkg/asset/templates/content/bootkube/09-openshift-service-cert-signer-namespace.go create mode 100644 pkg/asset/templates/content/bootkube/app-version-kind.go create mode 100644 pkg/asset/templates/content/bootkube/app-version-tectonic-network.go create mode 100644 pkg/asset/templates/content/bootkube/cvo-overrides.go create mode 100644 pkg/asset/templates/content/bootkube/etcd-service-endpoints.go create mode 100644 pkg/asset/templates/content/bootkube/etcd-service.go create mode 100644 pkg/asset/templates/content/bootkube/kube-cloud-config.go create mode 100644 pkg/asset/templates/content/bootkube/kube-system-configmap-etcd-serving-ca.go create mode 100644 pkg/asset/templates/content/bootkube/kube-system-configmap-root-ca.go create mode 100644 pkg/asset/templates/content/bootkube/kube-system-secret-etcd-client.go create mode 100644 pkg/asset/templates/content/bootkube/legacy-cvo-overrides.go create mode 100644 pkg/asset/templates/content/bootkube/machine-config-server-tls-secret.go create mode 100644 pkg/asset/templates/content/bootkube/openshift-service-cert-signer-ca-secret.go create mode 100644 pkg/asset/templates/content/bootkube/pull.go create mode 100644 pkg/asset/templates/content/bootkube/tectonic-network-operator.go create mode 100644 pkg/asset/templates/content/helper.go create mode 100644 pkg/asset/templates/content/tectonic/binding-discovery.go create mode 100644 pkg/asset/templates/content/tectonic/cloud-creds-secret.go create mode 100644 pkg/asset/templates/content/tectonic/kube-addon-00-appversion.go create mode 100644 pkg/asset/templates/content/tectonic/kube-addon-01-operator.go create mode 100644 pkg/asset/templates/content/tectonic/role-admin.go create mode 100644 pkg/asset/templates/content/tectonic/role-cloud-creds-secret-reader.go create mode 100644 pkg/asset/templates/content/tectonic/role-user.go create mode 100644 pkg/asset/templates/content/tectonic/tectonic-system-00-binding-admin.go create mode 100644 pkg/asset/templates/content/tectonic/tectonic-system-02-pull.go create mode 100644 pkg/asset/templates/templates.go diff --git a/cmd/openshift-install/create.go b/cmd/openshift-install/create.go index 7324bd50485..e87632e5346 100644 --- a/cmd/openshift-install/create.go +++ b/cmd/openshift-install/create.go @@ -25,6 +25,7 @@ import ( "github.com/openshift/installer/pkg/asset/installconfig" "github.com/openshift/installer/pkg/asset/kubeconfig" "github.com/openshift/installer/pkg/asset/manifests" + "github.com/openshift/installer/pkg/asset/templates" destroybootstrap "github.com/openshift/installer/pkg/destroy/bootstrap" ) @@ -59,6 +60,16 @@ var ( assets: []asset.WritableAsset{&manifests.Manifests{}, &manifests.Tectonic{}}, } + manifestTemplatesTarget = target{ + name: "Manifest templates", + command: &cobra.Command{ + Use: "manifest-templates", + Short: "Generates the unrendered Kubernetes manifest templates", + Long: "", + }, + assets: []asset.WritableAsset{&templates.Templates{}}, + } + ignitionConfigsTarget = target{ name: "Ignition Configs", command: &cobra.Command{ @@ -84,7 +95,7 @@ var ( assets: []asset.WritableAsset{&cluster.TerraformVariables{}, &kubeconfig.Admin{}, &cluster.Cluster{}}, } - targets = []target{installConfigTarget, manifestsTarget, ignitionConfigsTarget, clusterTarget} + targets = []target{installConfigTarget, manifestTemplatesTarget, manifestsTarget, ignitionConfigsTarget, clusterTarget} ) // Deprecated: Use 'create' subcommands instead. diff --git a/pkg/asset/manifests/content/bootkube/01-tectonic-namespace.go b/data/data/manifests/bootkube/01-tectonic-namespace.yaml similarity index 58% rename from pkg/asset/manifests/content/bootkube/01-tectonic-namespace.go rename to data/data/manifests/bootkube/01-tectonic-namespace.yaml index 1d52833ea23..381947e2e20 100644 --- a/pkg/asset/manifests/content/bootkube/01-tectonic-namespace.go +++ b/data/data/manifests/bootkube/01-tectonic-namespace.yaml @@ -1,9 +1,3 @@ -package bootkube - -const ( - // TectonicNamespace is the constant to represent contents of Tectonic_Namespace.yaml file - TectonicNamespace = ` ---- apiVersion: v1 kind: Namespace metadata: @@ -11,5 +5,3 @@ metadata: labels: # network policy can only select by labels name: tectonic-system openshift.io/run-level: "1" -` -) diff --git a/pkg/asset/manifests/content/bootkube/03-openshift-web-console-namespace.go b/data/data/manifests/bootkube/03-openshift-web-console-namespace.yaml similarity index 56% rename from pkg/asset/manifests/content/bootkube/03-openshift-web-console-namespace.go rename to data/data/manifests/bootkube/03-openshift-web-console-namespace.yaml index 9a492509f63..cbea3467240 100644 --- a/pkg/asset/manifests/content/bootkube/03-openshift-web-console-namespace.go +++ b/data/data/manifests/bootkube/03-openshift-web-console-namespace.yaml @@ -1,9 +1,3 @@ -package bootkube - -const ( - // OpenshiftWebConsoleNamespace is the constant to represent contents of Openshift_WebConsoleNamespace.yaml file - OpenshiftWebConsoleNamespace = ` ---- apiVersion: v1 kind: Namespace metadata: @@ -12,5 +6,3 @@ metadata: name: openshift-web-console labels: name: openshift-web-console -` -) diff --git a/data/data/manifests/bootkube/04-openshift-machine-config-operator.yaml b/data/data/manifests/bootkube/04-openshift-machine-config-operator.yaml new file mode 100644 index 00000000000..83c8515e59a --- /dev/null +++ b/data/data/manifests/bootkube/04-openshift-machine-config-operator.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: openshift-machine-config-operator + labels: + name: openshift-machine-config-operator + openshift.io/run-level: "1" diff --git a/pkg/asset/manifests/content/bootkube/05-openshift-cluster-api-namespace.go b/data/data/manifests/bootkube/05-openshift-cluster-api-namespace.yaml similarity index 53% rename from pkg/asset/manifests/content/bootkube/05-openshift-cluster-api-namespace.go rename to data/data/manifests/bootkube/05-openshift-cluster-api-namespace.yaml index 5cdc67c96e6..7dabda5f37a 100644 --- a/pkg/asset/manifests/content/bootkube/05-openshift-cluster-api-namespace.go +++ b/data/data/manifests/bootkube/05-openshift-cluster-api-namespace.yaml @@ -1,9 +1,3 @@ -package bootkube - -const ( - // OpenshiftClusterAPINamespace is the constant to represent contents of Openshift_ClusterApiNamespace.yaml file - OpenshiftClusterAPINamespace = ` ---- apiVersion: v1 kind: Namespace metadata: @@ -12,5 +6,3 @@ metadata: labels: name: openshift-cluster-api openshift.io/run-level: "1" -` -) diff --git a/data/data/manifests/bootkube/09-openshift-service-cert-signer-namespace.yaml b/data/data/manifests/bootkube/09-openshift-service-cert-signer-namespace.yaml new file mode 100644 index 00000000000..a5fb50527a6 --- /dev/null +++ b/data/data/manifests/bootkube/09-openshift-service-cert-signer-namespace.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Namespace +metadata: + # This is the namespace used to hold the service-serving-cert-signer. + name: openshift-service-cert-signer + labels: + openshift.io/run-level: "1" diff --git a/pkg/asset/manifests/content/bootkube/app-version-kind.go b/data/data/manifests/bootkube/app-version-kind.yaml similarity index 62% rename from pkg/asset/manifests/content/bootkube/app-version-kind.go rename to data/data/manifests/bootkube/app-version-kind.yaml index 676ffb48bc9..ebcd04e9ebe 100644 --- a/pkg/asset/manifests/content/bootkube/app-version-kind.go +++ b/data/data/manifests/bootkube/app-version-kind.yaml @@ -1,9 +1,3 @@ -package bootkube - -const ( - // AppVersionKind is the constant to represent contents of App_VersionKind.yaml file - AppVersionKind = ` ---- apiVersion: "apiextensions.k8s.io/v1beta1" kind: "CustomResourceDefinition" metadata: @@ -14,5 +8,3 @@ spec: names: plural: "appversions" kind: "AppVersion" -` -) diff --git a/pkg/asset/manifests/content/bootkube/app-version-tectonic-network.go b/data/data/manifests/bootkube/app-version-tectonic-network.yaml similarity index 60% rename from pkg/asset/manifests/content/bootkube/app-version-tectonic-network.go rename to data/data/manifests/bootkube/app-version-tectonic-network.yaml index 4efeaa54971..860ea3dbbc5 100644 --- a/pkg/asset/manifests/content/bootkube/app-version-tectonic-network.go +++ b/data/data/manifests/bootkube/app-version-tectonic-network.yaml @@ -1,9 +1,3 @@ -package bootkube - -const ( - // AppVersionTectonicNetwork is the constant to represent contents of App_VersionTectonicNetwork.yaml file - AppVersionTectonicNetwork = ` ---- apiVersion: tco.coreos.com/v1 kind: AppVersion metadata: @@ -19,5 +13,3 @@ status: paused: false upgradereq: 1 upgradecomp: 0 -` -) diff --git a/data/data/manifests/bootkube/cvo-overrides.yaml.template b/data/data/manifests/bootkube/cvo-overrides.yaml.template new file mode 100644 index 00000000000..9893865bd7d --- /dev/null +++ b/data/data/manifests/bootkube/cvo-overrides.yaml.template @@ -0,0 +1,17 @@ +apiVersion: config.openshift.io/v1 +kind: ClusterVersion +metadata: + namespace: openshift-cluster-version + name: version +spec: + upstream: http://localhost:8080/graph + channel: fast + clusterID: {{.CVOClusterID}} + overrides: + - kind: Deployment # this conflicts with kube-core-operator + namespace: openshift-cluster-network-operator + name: cluster-network-operator + unmanaged: true + - kind: APIService # packages.apps.redhat.com fails to start properly + name: v1alpha1.packages.apps.redhat.com + unmanaged: true diff --git a/data/data/manifests/bootkube/etcd-service-endpoints.yaml.template b/data/data/manifests/bootkube/etcd-service-endpoints.yaml.template new file mode 100644 index 00000000000..2ae2abd0f02 --- /dev/null +++ b/data/data/manifests/bootkube/etcd-service-endpoints.yaml.template @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Endpoints +metadata: + name: etcd + namespace: kube-system + annotations: + alpha.installer.openshift.io/dns-suffix: {{.EtcdEndpointDNSSuffix}} +subsets: +- addresses: +{{- range $idx, $member := .EtcdEndpointHostnames }} + - ip: 192.0.2.{{ add $idx 1 }} + hostname: {{ $member }} +{{- end }} + ports: + - name: etcd + port: 2379 + protocol: TCP diff --git a/pkg/asset/manifests/content/bootkube/etcd-service.go b/data/data/manifests/bootkube/etcd-service.yaml similarity index 63% rename from pkg/asset/manifests/content/bootkube/etcd-service.go rename to data/data/manifests/bootkube/etcd-service.yaml index 3e1b3bc5961..90508cb80b4 100644 --- a/pkg/asset/manifests/content/bootkube/etcd-service.go +++ b/data/data/manifests/bootkube/etcd-service.yaml @@ -1,9 +1,3 @@ -package bootkube - -const ( - // EtcdServiceKubeSystem is the constant to represent contents of etcd-service.yaml file - EtcdServiceKubeSystem = ` ---- apiVersion: v1 kind: Service metadata: @@ -18,5 +12,3 @@ spec: - name: etcd port: 2379 protocol: TCP -` -) diff --git a/data/data/manifests/bootkube/kube-cloud-config.yaml b/data/data/manifests/bootkube/kube-cloud-config.yaml new file mode 100644 index 00000000000..b42fdadba67 --- /dev/null +++ b/data/data/manifests/bootkube/kube-cloud-config.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: kube-cloud-cfg + namespace: kube-system +type: Opaque +data: + config: "" diff --git a/data/data/manifests/bootkube/kube-system-configmap-etcd-serving-ca.yaml.template b/data/data/manifests/bootkube/kube-system-configmap-etcd-serving-ca.yaml.template new file mode 100644 index 00000000000..6230c71e080 --- /dev/null +++ b/data/data/manifests/bootkube/kube-system-configmap-etcd-serving-ca.yaml.template @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: etcd-serving-ca + namespace: kube-system +data: + ca-bundle.crt: | + {{.EtcdCaCert}} diff --git a/data/data/manifests/bootkube/kube-system-configmap-root-ca.yaml.template b/data/data/manifests/bootkube/kube-system-configmap-root-ca.yaml.template new file mode 100644 index 00000000000..b621f125af2 --- /dev/null +++ b/data/data/manifests/bootkube/kube-system-configmap-root-ca.yaml.template @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: root-ca + namespace: kube-system +data: + ca.crt: {{.RootCaCert}} diff --git a/data/data/manifests/bootkube/kube-system-secret-etcd-client.yaml.template b/data/data/manifests/bootkube/kube-system-secret-etcd-client.yaml.template new file mode 100644 index 00000000000..2e11a2ee605 --- /dev/null +++ b/data/data/manifests/bootkube/kube-system-secret-etcd-client.yaml.template @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: etcd-client + namespace: kube-system +type: SecretTypeTLS +data: + tls.crt: {{ .EtcdClientCert }} + tls.key: {{ .EtcdClientKey }} diff --git a/data/data/manifests/bootkube/legacy-cvo-overrides.yaml.template b/data/data/manifests/bootkube/legacy-cvo-overrides.yaml.template new file mode 100644 index 00000000000..216f6f6be83 --- /dev/null +++ b/data/data/manifests/bootkube/legacy-cvo-overrides.yaml.template @@ -0,0 +1,16 @@ +apiVersion: clusterversion.openshift.io/v1 +kind: CVOConfig +metadata: + namespace: openshift-cluster-version + name: cluster-version-operator +upstream: http://localhost:8080/graph +channel: fast +clusterID: {{.CVOClusterID}} +overrides: +- kind: Deployment # this conflicts with kube-core-operator + namespace: openshift-cluster-network-operator + name: cluster-network-operator + unmanaged: true +- kind: APIService # packages.apps.redhat.com fails to start properly + name: v1alpha1.packages.apps.redhat.com + unmanaged: true diff --git a/data/data/manifests/bootkube/machine-config-server-tls-secret.yaml.template b/data/data/manifests/bootkube/machine-config-server-tls-secret.yaml.template new file mode 100644 index 00000000000..2e69149bd4b --- /dev/null +++ b/data/data/manifests/bootkube/machine-config-server-tls-secret.yaml.template @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: machine-config-server-tls + namespace: openshift-machine-config-operator +type: Opaque +data: + tls.crt: {{.McsTLSCert}} + tls.key: {{.McsTLSKey}} diff --git a/data/data/manifests/bootkube/openshift-service-cert-signer-ca-secret.yaml.template b/data/data/manifests/bootkube/openshift-service-cert-signer-ca-secret.yaml.template new file mode 100644 index 00000000000..38399febc43 --- /dev/null +++ b/data/data/manifests/bootkube/openshift-service-cert-signer-ca-secret.yaml.template @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: service-serving-cert-signer-signing-key + namespace: openshift-service-cert-signer +type: kubernetes.io/tls +data: + tls.crt: {{.ServiceServingCaCert}} + tls.key: {{.ServiceServingCaKey}} diff --git a/pkg/asset/manifests/content/bootkube/pull.go b/data/data/manifests/bootkube/pull.yaml.template similarity index 56% rename from pkg/asset/manifests/content/bootkube/pull.go rename to data/data/manifests/bootkube/pull.yaml.template index 20981cb442c..980ba3ee35a 100644 --- a/pkg/asset/manifests/content/bootkube/pull.go +++ b/data/data/manifests/bootkube/pull.yaml.template @@ -1,12 +1,3 @@ -package bootkube - -import ( - "text/template" -) - -var ( - // Pull is the constant to represent contents of pull.yaml file - Pull = template.Must(template.New("pull.json").Parse(` { "apiVersion": "v1", "kind": "Secret", @@ -19,5 +10,3 @@ var ( ".dockerconfigjson": "{{.PullSecret}}" } } -`)) -) diff --git a/pkg/asset/manifests/content/bootkube/tectonic-network-operator.go b/data/data/manifests/bootkube/tectonic-network-operator.yaml.template similarity index 85% rename from pkg/asset/manifests/content/bootkube/tectonic-network-operator.go rename to data/data/manifests/bootkube/tectonic-network-operator.yaml.template index d58a2481cc3..b481619f12a 100644 --- a/pkg/asset/manifests/content/bootkube/tectonic-network-operator.go +++ b/data/data/manifests/bootkube/tectonic-network-operator.yaml.template @@ -1,13 +1,3 @@ -package bootkube - -import ( - "text/template" -) - -var ( - // TectonicNetworkOperator represents the template variable for tectonic-network-operator.yaml file - TectonicNetworkOperator = template.Must(template.New("tectonic-network-operator.yaml").Parse(` ---- apiVersion: apps/v1beta2 kind: DaemonSet metadata: @@ -67,5 +57,3 @@ spec: rollingUpdate: maxUnavailable: 1 type: RollingUpdate -`)) -) diff --git a/data/data/manifests/tectonic/binding-discovery.yaml b/data/data/manifests/tectonic/binding-discovery.yaml new file mode 100644 index 00000000000..79154a8aff8 --- /dev/null +++ b/data/data/manifests/tectonic/binding-discovery.yaml @@ -0,0 +1,13 @@ +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: discovery +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:discovery +subjects: +- kind: Group + name: 'system:unauthenticated' +- kind: Group + name: 'system:authenticated' diff --git a/pkg/asset/manifests/content/tectonic/cloud-creds-secret.go b/data/data/manifests/tectonic/cloud-creds-secret.yaml.template similarity index 66% rename from pkg/asset/manifests/content/tectonic/cloud-creds-secret.go rename to data/data/manifests/tectonic/cloud-creds-secret.yaml.template index c1259e4c30e..913947b9436 100644 --- a/pkg/asset/manifests/content/tectonic/cloud-creds-secret.go +++ b/data/data/manifests/tectonic/cloud-creds-secret.yaml.template @@ -1,13 +1,3 @@ -package tectonic - -import ( - "text/template" -) - -var ( - // CloudCredsSecret is the constant to represent contents of corresponding yaml file - CloudCredsSecret = template.Must(template.New("cloud-creds-secret.yaml").Parse(` ---- kind: Secret apiVersion: v1 metadata: @@ -24,5 +14,3 @@ data: {{- else if .CloudCreds.OpenStack}} clouds.yaml: {{.CloudCreds.OpenStack.Base64encodeCloudCreds}} {{- end}} -`)) -) diff --git a/pkg/asset/manifests/content/tectonic/kube-addon-00-appversion.go b/data/data/manifests/tectonic/kube-addon-00-appversion.yaml similarity index 62% rename from pkg/asset/manifests/content/tectonic/kube-addon-00-appversion.go rename to data/data/manifests/tectonic/kube-addon-00-appversion.yaml index 30fda5308e0..ac36ad9c142 100644 --- a/pkg/asset/manifests/content/tectonic/kube-addon-00-appversion.go +++ b/data/data/manifests/tectonic/kube-addon-00-appversion.yaml @@ -1,9 +1,3 @@ -package tectonic - -const ( - // AppVersionKubeAddon is the variable/constant representing the contents of the respective file - AppVersionKubeAddon = ` ---- apiVersion: tco.coreos.com/v1 kind: AppVersion metadata: @@ -19,5 +13,3 @@ status: paused: false upgradereq: 1 upgradecomp: 0 -` -) diff --git a/pkg/asset/manifests/content/tectonic/kube-addon-01-operator.go b/data/data/manifests/tectonic/kube-addon-01-operator.yaml.template similarity index 84% rename from pkg/asset/manifests/content/tectonic/kube-addon-01-operator.go rename to data/data/manifests/tectonic/kube-addon-01-operator.yaml.template index 33fb6273d7a..303533e96b0 100644 --- a/pkg/asset/manifests/content/tectonic/kube-addon-01-operator.go +++ b/data/data/manifests/tectonic/kube-addon-01-operator.yaml.template @@ -1,13 +1,3 @@ -package tectonic - -import ( - "text/template" -) - -var ( - // KubeAddonOperator is the variable/constant representing the contents of the respective file - KubeAddonOperator = template.Must(template.New("kube-addon-operator.yaml").Parse(` ---- apiVersion: apps/v1beta2 kind: Deployment metadata: @@ -59,5 +49,3 @@ spec: items: - key: addon-config path: addon-config -`)) -) diff --git a/data/data/manifests/tectonic/role-admin.yaml b/data/data/manifests/tectonic/role-admin.yaml new file mode 100644 index 00000000000..c843c933517 --- /dev/null +++ b/data/data/manifests/tectonic/role-admin.yaml @@ -0,0 +1,10 @@ +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: admin +rules: +- apiGroups: ["*"] + resources: ["*"] + verbs: ["*"] +- nonResourceURLs: ["*"] + verbs: ["*"] diff --git a/pkg/asset/manifests/content/tectonic/role-cloud-creds-secret-reader.go b/data/data/manifests/tectonic/role-cloud-creds-secret-reader.yaml.template similarity index 62% rename from pkg/asset/manifests/content/tectonic/role-cloud-creds-secret-reader.go rename to data/data/manifests/tectonic/role-cloud-creds-secret-reader.yaml.template index fd6b08eb703..4c7a3be9259 100644 --- a/pkg/asset/manifests/content/tectonic/role-cloud-creds-secret-reader.go +++ b/data/data/manifests/tectonic/role-cloud-creds-secret-reader.yaml.template @@ -1,13 +1,3 @@ -package tectonic - -import ( - "text/template" -) - -var ( - // RoleCloudCredsSecretReader is the variable to represent contents of corresponding file - RoleCloudCredsSecretReader = template.Must(template.New("role-cloud-creds-secret-reader.yaml").Parse(` ---- kind: Role apiVersion: rbac.authorization.k8s.io/v1beta1 metadata: @@ -26,5 +16,3 @@ rules: resourceNames: ["openstack-creds"] {{- end}} verbs: ["get"] -`)) -) diff --git a/data/data/manifests/tectonic/role-user.yaml b/data/data/manifests/tectonic/role-user.yaml new file mode 100644 index 00000000000..9a0e4e7d331 --- /dev/null +++ b/data/data/manifests/tectonic/role-user.yaml @@ -0,0 +1,67 @@ +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: user +rules: +- apiGroups: [""] + resources: [ + "bindings", "configmaps", "events", "pods", "replicationcontrollers", + "secrets", "services", "serviceaccounts", + "pods/attach", + "pods/binding", + "pods/exec", + "pods/log", + "pods/portforward", + "pods/proxy", + "pods/status", + "replicationcontrollers/scale", + "replicationcontrollers/status", + "services/proxy", + "services/status" + ] + verbs: ["*"] + nonResourceURLs: [] + +- apiGroups: [""] + resources: [ + "componentstatuses", "endpoints", "limitranges", "nodes", "nodes/proxy", "nodes/status", + "namespaces", "namespaces/status", "namespaces/finalize", + "persistentvolumeclaims", "persistentvolumeclaims/status", "persistentvolumes", "resourcequotas", + "resourcequotas/status" + ] + verbs: ["get", "list", "watch", "proxy", "redirect"] + nonResourceURLs: [] + +- apiGroups: ["apps", "batch", "autoscaling", "policy"] + resources: ["*"] + verbs: ["*"] + nonResourceURLs: [] + +- apiGroups: ["extensions"] + resources: [ + "daemonsets", "deployments", "horizontalpodautoscalers", "ingresses", + "jobs", "replicasets", "replicationcontrollers", + + "daemonsets/status", + "deployments/rollback", + "deployments/scale", + "deployments/status", + "horizontalpodautoscalers/status", + "ingresses/status", + "jobs/status", + "replicasets/scale", + "replicasets/status", + "replicationcontrollers/scale" + ] + verbs: ["*"] + nonResourceURLs: [] + +- apiGroups: ["extensions"] + resources: ["networkpolicies", "thirdpartyresources"] + verbs: ["get", "list", "watch", "proxy", "redirect"] + nonResourceURLs: [] + +- apiGroups: ["rbac.authorization.k8s.io"] + resources: ["*"] + verbs: ["get", "list", "watch", "proxy", "redirect"] + nonResourceURLs: [] diff --git a/data/data/manifests/tectonic/tectonic-system-00-binding-admin.yaml b/data/data/manifests/tectonic/tectonic-system-00-binding-admin.yaml new file mode 100644 index 00000000000..4ba6056898a --- /dev/null +++ b/data/data/manifests/tectonic/tectonic-system-00-binding-admin.yaml @@ -0,0 +1,15 @@ +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: admin-user +subjects: +- kind: ServiceAccount + namespace: tectonic-system + name: default +- kind: ServiceAccount + namespace: openshift-ingress + name: tectonic-ingress-controller-operator +roleRef: + kind: ClusterRole + name: cluster-admin + apiGroup: rbac.authorization.k8s.io diff --git a/data/data/manifests/tectonic/tectonic-system-02-pull.yaml.template b/data/data/manifests/tectonic/tectonic-system-02-pull.yaml.template new file mode 100644 index 00000000000..370a0729398 --- /dev/null +++ b/data/data/manifests/tectonic/tectonic-system-02-pull.yaml.template @@ -0,0 +1,12 @@ +{ + "apiVersion": "v1", + "kind": "Secret", + "type": "kubernetes.io/dockerconfigjson", + "metadata": { + "namespace": "tectonic-system", + "name": "coreos-pull-secret" + }, + "data": { + ".dockerconfigjson": "{{.PullSecret}}" + } +} diff --git a/pkg/asset/manifests/content/bootkube/04-openshift-machine-config-operator.go b/pkg/asset/manifests/content/bootkube/04-openshift-machine-config-operator.go deleted file mode 100644 index 91811be1dd3..00000000000 --- a/pkg/asset/manifests/content/bootkube/04-openshift-machine-config-operator.go +++ /dev/null @@ -1,14 +0,0 @@ -package bootkube - -const ( - // OpenshiftMachineConfigOperator is the constant to represent contents of Openshift_MachineConfigOperator.yaml file - OpenshiftMachineConfigOperator = ` -apiVersion: v1 -kind: Namespace -metadata: - name: openshift-machine-config-operator - labels: - name: openshift-machine-config-operator - openshift.io/run-level: "1" -` -) diff --git a/pkg/asset/manifests/content/bootkube/09-openshift-service-cert-signer-namespace.go b/pkg/asset/manifests/content/bootkube/09-openshift-service-cert-signer-namespace.go deleted file mode 100644 index b2792bd7686..00000000000 --- a/pkg/asset/manifests/content/bootkube/09-openshift-service-cert-signer-namespace.go +++ /dev/null @@ -1,15 +0,0 @@ -package bootkube - -const ( - // OpenshiftServiceCertSignerNamespace is the constant to represent the contents of 09-openshift-service-signer-namespace.yaml - OpenshiftServiceCertSignerNamespace = ` ---- -apiVersion: v1 -kind: Namespace -metadata: - # This is the namespace used to hold the service-serving-cert-signer. - name: openshift-service-cert-signer - labels: - openshift.io/run-level: "1" -` -) diff --git a/pkg/asset/manifests/content/bootkube/cvo-overrides.go b/pkg/asset/manifests/content/bootkube/cvo-overrides.go deleted file mode 100644 index be05ab9f7fa..00000000000 --- a/pkg/asset/manifests/content/bootkube/cvo-overrides.go +++ /dev/null @@ -1,55 +0,0 @@ -package bootkube - -import ( - "text/template" -) - -var ( - // CVOOverrides is the constant to represent contents of cvo-override.yaml file - // This is a gate to prevent CVO from installing these operators which is conflicting - // with already owned resources by tectonic-operators. - // This files can be dropped when the overrides list becomes empty. - // IMPORTANT: You must also edit LegacyCVOOverrides - CVOOverrides = template.Must(template.New("cvo-override.yaml").Parse(` -apiVersion: config.openshift.io/v1 -kind: ClusterVersion -metadata: - namespace: openshift-cluster-version - name: version -spec: - upstream: http://localhost:8080/graph - channel: fast - clusterID: {{.CVOClusterID}} - overrides: - - kind: Deployment # this conflicts with kube-core-operator - namespace: openshift-cluster-network-operator - name: cluster-network-operator - unmanaged: true - - kind: APIService # packages.apps.redhat.com fails to start properly - name: v1alpha1.packages.apps.redhat.com - unmanaged: true -`)) - - // LegacyCVOOverrides is the constant to represent contents of legacy-cvo-override.yaml file - // This is a gate to prevent CVO from installing these operators which is conflicting - // with already owned resources by tectonic-operators. - // This files can be dropped when the overrides list becomes empty. - LegacyCVOOverrides = template.Must(template.New("cvo-override.yaml").Parse(` -apiVersion: clusterversion.openshift.io/v1 -kind: CVOConfig -metadata: - namespace: openshift-cluster-version - name: cluster-version-operator -upstream: http://localhost:8080/graph -channel: fast -clusterID: {{.CVOClusterID}} -overrides: -- kind: Deployment # this conflicts with kube-core-operator - namespace: openshift-cluster-network-operator - name: cluster-network-operator - unmanaged: true -- kind: APIService # packages.apps.redhat.com fails to start properly - name: v1alpha1.packages.apps.redhat.com - unmanaged: true -`)) -) diff --git a/pkg/asset/manifests/content/bootkube/etcd-service-endpoints.go b/pkg/asset/manifests/content/bootkube/etcd-service-endpoints.go deleted file mode 100644 index 8306c52e8ba..00000000000 --- a/pkg/asset/manifests/content/bootkube/etcd-service-endpoints.go +++ /dev/null @@ -1,34 +0,0 @@ -package bootkube - -import ( - "text/template" -) - -var customTmplFuncs = template.FuncMap{ - "add": func(i, j int) int { - return i + j - }, -} - -var ( - // EtcdServiceEndpointsKubeSystem is the constant to represent contents of etcd-service-endpoints.yaml file. - EtcdServiceEndpointsKubeSystem = template.Must(template.New("etcd-service-endpoints.yaml").Funcs(customTmplFuncs).Parse(` -apiVersion: v1 -kind: Endpoints -metadata: - name: etcd - namespace: kube-system - annotations: - alpha.installer.openshift.io/dns-suffix: {{.EtcdEndpointDNSSuffix}} -subsets: -- addresses: -{{- range $idx, $member := .EtcdEndpointHostnames }} - - ip: 192.0.2.{{ add $idx 1 }} - hostname: {{ $member }} -{{- end }} - ports: - - name: etcd - port: 2379 - protocol: TCP -`)) -) diff --git a/pkg/asset/manifests/content/bootkube/kube-cloud-config.go b/pkg/asset/manifests/content/bootkube/kube-cloud-config.go deleted file mode 100644 index 5463525d053..00000000000 --- a/pkg/asset/manifests/content/bootkube/kube-cloud-config.go +++ /dev/null @@ -1,19 +0,0 @@ -package bootkube - -import ( - "text/template" -) - -var ( - // KubeCloudConfig is the constant to represent contents of kube_cloudconfig.yaml file - KubeCloudConfig = template.Must(template.New("kube-cloud-config.yaml").Parse(` -apiVersion: v1 -kind: Secret -metadata: - name: kube-cloud-cfg - namespace: kube-system -type: Opaque -data: - config: "" -`)) -) diff --git a/pkg/asset/manifests/content/bootkube/kube-system-configmap-etcd-serving-ca.go b/pkg/asset/manifests/content/bootkube/kube-system-configmap-etcd-serving-ca.go deleted file mode 100644 index a0ed32718a0..00000000000 --- a/pkg/asset/manifests/content/bootkube/kube-system-configmap-etcd-serving-ca.go +++ /dev/null @@ -1,18 +0,0 @@ -package bootkube - -import "text/template" - -var ( - // KubeSystemConfigmapEtcdServingCA is the constant to represent contents of kube-system-configmap-etcd-serving-ca.yaml file - KubeSystemConfigmapEtcdServingCA = template.Must(template.New("kube-system-configmap-etcd-serving-ca.yaml").Parse(` ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: etcd-serving-ca - namespace: kube-system -data: - ca-bundle.crt: | - {{.EtcdCaCert}} -`)) -) diff --git a/pkg/asset/manifests/content/bootkube/kube-system-configmap-root-ca.go b/pkg/asset/manifests/content/bootkube/kube-system-configmap-root-ca.go deleted file mode 100644 index 4a4ef3fa160..00000000000 --- a/pkg/asset/manifests/content/bootkube/kube-system-configmap-root-ca.go +++ /dev/null @@ -1,17 +0,0 @@ -package bootkube - -import "text/template" - -var ( - // KubeSystemConfigmapRootCA is the constant to represent contents of kube-system-configmap-root-ca.yaml file - KubeSystemConfigmapRootCA = template.Must(template.New("kube-system-configmap-root-ca.yaml").Parse(` ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: root-ca - namespace: kube-system -data: - ca.crt: {{.RootCaCert}} -`)) -) diff --git a/pkg/asset/manifests/content/bootkube/kube-system-secret-etcd-client.go b/pkg/asset/manifests/content/bootkube/kube-system-secret-etcd-client.go deleted file mode 100644 index b7b91b2d621..00000000000 --- a/pkg/asset/manifests/content/bootkube/kube-system-secret-etcd-client.go +++ /dev/null @@ -1,20 +0,0 @@ -package bootkube - -import ( - "text/template" -) - -var ( - // KubeSystemSecretEtcdClient is the constant to represent contents of kube-system-secret-etcd-client.yaml file - KubeSystemSecretEtcdClient = template.Must(template.New("kube-system-secret-etcd-client.yaml").Parse(` -apiVersion: v1 -kind: Secret -metadata: - name: etcd-client - namespace: kube-system -type: SecretTypeTLS -data: - tls.crt: {{ .EtcdClientCert }} - tls.key: {{ .EtcdClientKey }} -`)) -) diff --git a/pkg/asset/manifests/content/bootkube/machine-config-server-tls-secret.go b/pkg/asset/manifests/content/bootkube/machine-config-server-tls-secret.go deleted file mode 100644 index 5fe0c6c9e89..00000000000 --- a/pkg/asset/manifests/content/bootkube/machine-config-server-tls-secret.go +++ /dev/null @@ -1,20 +0,0 @@ -package bootkube - -import ( - "text/template" -) - -var ( - // MachineConfigServerTLSSecret is the constant to represent contents of machine_configservertlssecret.yaml file - MachineConfigServerTLSSecret = template.Must(template.New("machine-config-server-tls-secret.yaml").Parse(` -apiVersion: v1 -kind: Secret -metadata: - name: machine-config-server-tls - namespace: openshift-machine-config-operator -type: Opaque -data: - tls.crt: {{.McsTLSCert}} - tls.key: {{.McsTLSKey}} -`)) -) diff --git a/pkg/asset/manifests/content/bootkube/openshift-service-cert-signer-ca-secret.go b/pkg/asset/manifests/content/bootkube/openshift-service-cert-signer-ca-secret.go deleted file mode 100644 index 39c73d48b3f..00000000000 --- a/pkg/asset/manifests/content/bootkube/openshift-service-cert-signer-ca-secret.go +++ /dev/null @@ -1,20 +0,0 @@ -package bootkube - -import ( - "text/template" -) - -var ( - // OpenshiftServiceCertSignerSecret is the constant to represent the contents of openshift-service-signer-secret.yaml - OpenshiftServiceCertSignerSecret = template.Must(template.New("openshift-service-signer-secret.yaml").Parse(` -apiVersion: v1 -kind: Secret -metadata: - name: service-serving-cert-signer-signing-key - namespace: openshift-service-cert-signer -type: kubernetes.io/tls -data: - tls.crt: {{.ServiceServingCaCert}} - tls.key: {{.ServiceServingCaKey}} -`)) -) diff --git a/pkg/asset/manifests/content/tectonic/binding-discovery.go b/pkg/asset/manifests/content/tectonic/binding-discovery.go deleted file mode 100644 index 79dc5febbf1..00000000000 --- a/pkg/asset/manifests/content/tectonic/binding-discovery.go +++ /dev/null @@ -1,21 +0,0 @@ -package tectonic - -const ( - // BindingDiscovery is the variable/constant representing the contents of the respective file - BindingDiscovery = ` ---- -kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1beta1 -metadata: - name: discovery -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: system:discovery -subjects: - - kind: Group - name: 'system:unauthenticated' - - kind: Group - name: 'system:authenticated' -` -) diff --git a/pkg/asset/manifests/content/tectonic/role-admin.go b/pkg/asset/manifests/content/tectonic/role-admin.go deleted file mode 100644 index 57f95300fd1..00000000000 --- a/pkg/asset/manifests/content/tectonic/role-admin.go +++ /dev/null @@ -1,18 +0,0 @@ -package tectonic - -const ( - // RoleAdmin is the variable/constant representing the contents of the respective file - RoleAdmin = ` ---- -kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1beta1 -metadata: - name: admin -rules: - - apiGroups: ["*"] - resources: ["*"] - verbs: ["*"] - - nonResourceURLs: ["*"] - verbs: ["*"] -` -) diff --git a/pkg/asset/manifests/content/tectonic/role-user.go b/pkg/asset/manifests/content/tectonic/role-user.go deleted file mode 100644 index ac0e40fe02c..00000000000 --- a/pkg/asset/manifests/content/tectonic/role-user.go +++ /dev/null @@ -1,75 +0,0 @@ -package tectonic - -const ( - // RoleUser is the variable/constant representing the contents of the respective file - RoleUser = ` ---- -kind: ClusterRole -apiVersion: rbac.authorization.k8s.io/v1beta1 -metadata: - name: user -rules: - - apiGroups: [""] - resources: [ - "bindings", "configmaps", "events", "pods", "replicationcontrollers", - "secrets", "services", "serviceaccounts", - "pods/attach", - "pods/binding", - "pods/exec", - "pods/log", - "pods/portforward", - "pods/proxy", - "pods/status", - "replicationcontrollers/scale", - "replicationcontrollers/status", - "services/proxy", - "services/status" - ] - verbs: ["*"] - nonResourceURLs: [] - - - apiGroups: [""] - resources: [ - "componentstatuses", "endpoints", "limitranges", "nodes", "nodes/proxy", "nodes/status", - "namespaces", "namespaces/status", "namespaces/finalize", - "persistentvolumeclaims", "persistentvolumeclaims/status", "persistentvolumes", "resourcequotas", - "resourcequotas/status" - ] - verbs: ["get", "list", "watch", "proxy", "redirect"] - nonResourceURLs: [] - - - apiGroups: ["apps", "batch", "autoscaling", "policy"] - resources: ["*"] - verbs: ["*"] - nonResourceURLs: [] - - - apiGroups: ["extensions"] - resources: [ - "daemonsets", "deployments", "horizontalpodautoscalers", "ingresses", - "jobs", "replicasets", "replicationcontrollers", - - "daemonsets/status", - "deployments/rollback", - "deployments/scale", - "deployments/status", - "horizontalpodautoscalers/status", - "ingresses/status", - "jobs/status", - "replicasets/scale", - "replicasets/status", - "replicationcontrollers/scale" - ] - verbs: ["*"] - nonResourceURLs: [] - - - apiGroups: ["extensions"] - resources: ["networkpolicies", "thirdpartyresources"] - verbs: ["get", "list", "watch", "proxy", "redirect"] - nonResourceURLs: [] - - - apiGroups: ["rbac.authorization.k8s.io"] - resources: ["*"] - verbs: ["get", "list", "watch", "proxy", "redirect"] - nonResourceURLs: [] -` -) diff --git a/pkg/asset/manifests/content/tectonic/tectonic-system-00-binding-admin.go b/pkg/asset/manifests/content/tectonic/tectonic-system-00-binding-admin.go deleted file mode 100644 index 59515947022..00000000000 --- a/pkg/asset/manifests/content/tectonic/tectonic-system-00-binding-admin.go +++ /dev/null @@ -1,23 +0,0 @@ -package tectonic - -const ( - // BindingAdmin is the variable/constant representing the contents of the respective file - BindingAdmin = ` ---- -kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1beta1 -metadata: - name: admin-user -subjects: - - kind: ServiceAccount - namespace: tectonic-system - name: default - - kind: ServiceAccount - namespace: openshift-ingress - name: tectonic-ingress-controller-operator -roleRef: - kind: ClusterRole - name: cluster-admin - apiGroup: rbac.authorization.k8s.io -` -) diff --git a/pkg/asset/manifests/content/tectonic/tectonic-system-02-pull.go b/pkg/asset/manifests/content/tectonic/tectonic-system-02-pull.go deleted file mode 100644 index 53c2973f855..00000000000 --- a/pkg/asset/manifests/content/tectonic/tectonic-system-02-pull.go +++ /dev/null @@ -1,23 +0,0 @@ -package tectonic - -import ( - "text/template" -) - -var ( - // PullTectonicSystem is the variable/constant representing the contents of the respective file - PullTectonicSystem = template.Must(template.New("tectonic-system-02-pull.json").Parse(` -{ - "apiVersion": "v1", - "kind": "Secret", - "type": "kubernetes.io/dockerconfigjson", - "metadata": { - "namespace": "tectonic-system", - "name": "coreos-pull-secret" - }, - "data": { - ".dockerconfigjson": "{{.PullSecret}}" - } -} -`)) -) diff --git a/pkg/asset/manifests/operators.go b/pkg/asset/manifests/operators.go index 2ed00d85e71..98419d1305d 100644 --- a/pkg/asset/manifests/operators.go +++ b/pkg/asset/manifests/operators.go @@ -13,7 +13,7 @@ import ( "github.com/openshift/installer/pkg/asset" "github.com/openshift/installer/pkg/asset/installconfig" - "github.com/openshift/installer/pkg/asset/manifests/content/bootkube" + "github.com/openshift/installer/pkg/asset/templates/content/bootkube" "github.com/openshift/installer/pkg/asset/tls" ) @@ -25,6 +25,12 @@ var ( kubeSysConfigPath = filepath.Join(manifestDir, "cluster-config.yaml") _ asset.WritableAsset = (*Manifests)(nil) + + customTmplFuncs = template.FuncMap{ + "add": func(i, j int) int { + return i + j + }, + } ) // Manifests generates the dependent operator config.yaml files @@ -54,6 +60,27 @@ func (m *Manifests) Dependencies() []asset.Asset { &tls.EtcdClientCertKey{}, &tls.MCSCertKey{}, &tls.KubeletCertKey{}, + + &bootkube.KubeCloudConfig{}, + &bootkube.MachineConfigServerTLSSecret{}, + &bootkube.OpenshiftServiceCertSignerSecret{}, + &bootkube.Pull{}, + &bootkube.TectonicNetworkOperator{}, + &bootkube.CVOOverrides{}, + &bootkube.LegacyCVOOverrides{}, + &bootkube.EtcdServiceEndpointsKubeSystem{}, + &bootkube.KubeSystemConfigmapEtcdServingCA{}, + &bootkube.KubeSystemConfigmapRootCA{}, + &bootkube.KubeSystemSecretEtcdClient{}, + + &bootkube.TectonicNamespace{}, + &bootkube.OpenshiftWebConsoleNamespace{}, + &bootkube.OpenshiftMachineConfigOperator{}, + &bootkube.OpenshiftClusterAPINamespace{}, + &bootkube.OpenshiftServiceCertSignerNamespace{}, + &bootkube.AppVersionKind{}, + &bootkube.AppVersionTectonicNetwork{}, + &bootkube.EtcdServiceKubeSystem{}, } } @@ -131,27 +158,68 @@ func (m *Manifests) generateBootKubeManifests(dependencies asset.Parents) []*ass EtcdEndpointDNSSuffix: installConfig.Config.BaseDomain, } + kubeCloudConfig := &bootkube.KubeCloudConfig{} + machineConfigServerTLSSecret := &bootkube.MachineConfigServerTLSSecret{} + openshiftServiceCertSignerSecret := &bootkube.OpenshiftServiceCertSignerSecret{} + pull := &bootkube.Pull{} + tectonicNetworkOperator := &bootkube.TectonicNetworkOperator{} + cVOOverrides := &bootkube.CVOOverrides{} + legacyCVOOverrides := &bootkube.LegacyCVOOverrides{} + etcdServiceEndpointsKubeSystem := &bootkube.EtcdServiceEndpointsKubeSystem{} + kubeSystemConfigmapEtcdServingCA := &bootkube.KubeSystemConfigmapEtcdServingCA{} + kubeSystemConfigmapRootCA := &bootkube.KubeSystemConfigmapRootCA{} + kubeSystemSecretEtcdClient := &bootkube.KubeSystemSecretEtcdClient{} + + tectonicNamespace := &bootkube.TectonicNamespace{} + openshiftWebConsoleNamespace := &bootkube.OpenshiftWebConsoleNamespace{} + openshiftMachineConfigOperator := &bootkube.OpenshiftMachineConfigOperator{} + openshiftClusterAPINamespace := &bootkube.OpenshiftClusterAPINamespace{} + openshiftServiceCertSignerNamespace := &bootkube.OpenshiftServiceCertSignerNamespace{} + appVersionKind := &bootkube.AppVersionKind{} + appVersionTectonicNetwork := &bootkube.AppVersionTectonicNetwork{} + etcdServiceKubeSystem := &bootkube.EtcdServiceKubeSystem{} + dependencies.Get( + kubeCloudConfig, + machineConfigServerTLSSecret, + openshiftServiceCertSignerSecret, + pull, + tectonicNetworkOperator, + cVOOverrides, + legacyCVOOverrides, + etcdServiceEndpointsKubeSystem, + kubeSystemConfigmapEtcdServingCA, + kubeSystemConfigmapRootCA, + kubeSystemSecretEtcdClient, + tectonicNamespace, + openshiftWebConsoleNamespace, + openshiftMachineConfigOperator, + openshiftClusterAPINamespace, + openshiftServiceCertSignerNamespace, + appVersionKind, + appVersionTectonicNetwork, + etcdServiceKubeSystem, + ) assetData := map[string][]byte{ - "kube-cloud-config.yaml": applyTemplateData(bootkube.KubeCloudConfig, templateData), - "machine-config-server-tls-secret.yaml": applyTemplateData(bootkube.MachineConfigServerTLSSecret, templateData), - "openshift-service-signer-secret.yaml": applyTemplateData(bootkube.OpenshiftServiceCertSignerSecret, templateData), - "pull.json": applyTemplateData(bootkube.Pull, templateData), - "tectonic-network-operator.yaml": applyTemplateData(bootkube.TectonicNetworkOperator, templateData), - "cvo-overrides.yaml": applyTemplateData(bootkube.CVOOverrides, templateData), - "legacy-cvo-overrides.yaml": applyTemplateData(bootkube.LegacyCVOOverrides, templateData), - "etcd-service-endpoints.yaml": applyTemplateData(bootkube.EtcdServiceEndpointsKubeSystem, templateData), - "kube-system-configmap-etcd-serving-ca.yaml": applyTemplateData(bootkube.KubeSystemConfigmapEtcdServingCA, templateData), - "kube-system-configmap-root-ca.yaml": applyTemplateData(bootkube.KubeSystemConfigmapRootCA, templateData), - "kube-system-secret-etcd-client.yaml": applyTemplateData(bootkube.KubeSystemSecretEtcdClient, templateData), - - "01-tectonic-namespace.yaml": []byte(bootkube.TectonicNamespace), - "03-openshift-web-console-namespace.yaml": []byte(bootkube.OpenshiftWebConsoleNamespace), - "04-openshift-machine-config-operator.yaml": []byte(bootkube.OpenshiftMachineConfigOperator), - "05-openshift-cluster-api-namespace.yaml": []byte(bootkube.OpenshiftClusterAPINamespace), - "09-openshift-service-signer-namespace.yaml": []byte(bootkube.OpenshiftServiceCertSignerNamespace), - "app-version-kind.yaml": []byte(bootkube.AppVersionKind), - "app-version-tectonic-network.yaml": []byte(bootkube.AppVersionTectonicNetwork), - "etcd-service.yaml": []byte(bootkube.EtcdServiceKubeSystem), + "kube-cloud-config.yaml": applyTemplateData(kubeCloudConfig.Files()[0].Data, templateData), + "machine-config-server-tls-secret.yaml": applyTemplateData(machineConfigServerTLSSecret.Files()[0].Data, templateData), + "openshift-service-signer-secret.yaml": applyTemplateData(openshiftServiceCertSignerSecret.Files()[0].Data, templateData), + "pull.json": applyTemplateData(pull.Files()[0].Data, templateData), + "tectonic-network-operator.yaml": applyTemplateData(tectonicNetworkOperator.Files()[0].Data, templateData), + "cvo-overrides.yaml": applyTemplateData(cVOOverrides.Files()[0].Data, templateData), + "legacy-cvo-overrides.yaml": applyTemplateData(legacyCVOOverrides.Files()[0].Data, templateData), + "etcd-service-endpoints.yaml": applyTemplateData(etcdServiceEndpointsKubeSystem.Files()[0].Data, templateData), + "kube-system-configmap-etcd-serving-ca.yaml": applyTemplateData(kubeSystemConfigmapEtcdServingCA.Files()[0].Data, templateData), + "kube-system-configmap-root-ca.yaml": applyTemplateData(kubeSystemConfigmapRootCA.Files()[0].Data, templateData), + "kube-system-secret-etcd-client.yaml": applyTemplateData(kubeSystemSecretEtcdClient.Files()[0].Data, templateData), + + "01-tectonic-namespace.yaml": []byte(tectonicNamespace.Files()[0].Data), + "03-openshift-web-console-namespace.yaml": []byte(openshiftWebConsoleNamespace.Files()[0].Data), + "04-openshift-machine-config-operator.yaml": []byte(openshiftMachineConfigOperator.Files()[0].Data), + "05-openshift-cluster-api-namespace.yaml": []byte(openshiftClusterAPINamespace.Files()[0].Data), + "09-openshift-service-signer-namespace.yaml": []byte(openshiftServiceCertSignerNamespace.Files()[0].Data), + "app-version-kind.yaml": []byte(appVersionKind.Files()[0].Data), + "app-version-tectonic-network.yaml": []byte(appVersionTectonicNetwork.Files()[0].Data), + "etcd-service.yaml": []byte(etcdServiceKubeSystem.Files()[0].Data), } files := make([]*asset.File, 0, len(assetData)) @@ -165,7 +233,8 @@ func (m *Manifests) generateBootKubeManifests(dependencies asset.Parents) []*ass return files } -func applyTemplateData(template *template.Template, templateData interface{}) []byte { +func applyTemplateData(data []byte, templateData interface{}) []byte { + template := template.Must(template.New("template").Funcs(customTmplFuncs).Parse(string(data))) buf := &bytes.Buffer{} if err := template.Execute(buf, templateData); err != nil { panic(err) diff --git a/pkg/asset/manifests/tectonic.go b/pkg/asset/manifests/tectonic.go index 1dd1c8feb4c..444b0ee13fc 100644 --- a/pkg/asset/manifests/tectonic.go +++ b/pkg/asset/manifests/tectonic.go @@ -14,7 +14,7 @@ import ( "github.com/openshift/installer/pkg/asset" "github.com/openshift/installer/pkg/asset/installconfig" "github.com/openshift/installer/pkg/asset/machines" - content "github.com/openshift/installer/pkg/asset/manifests/content/tectonic" + "github.com/openshift/installer/pkg/asset/templates/content/tectonic" "github.com/openshift/installer/pkg/asset/tls" ) @@ -51,6 +51,16 @@ func (t *Tectonic) Dependencies() []asset.Asset { &machines.Worker{}, &machines.Master{}, &kubeAddonOperator{}, + + &tectonic.BindingDiscovery{}, + &tectonic.AppVersionKubeAddon{}, + &tectonic.KubeAddonOperator{}, + &tectonic.RoleAdmin{}, + &tectonic.RoleUser{}, + &tectonic.BindingAdmin{}, + &tectonic.PullTectonicSystem{}, + &tectonic.CloudCredsSecret{}, + &tectonic.RoleCloudCredsSecretReader{}, } } @@ -97,25 +107,44 @@ func (t *Tectonic) Generate(dependencies asset.Parents) error { CloudCreds: cloudCreds, } + bindingDiscovery := &tectonic.BindingDiscovery{} + appVersionKubeAddon := &tectonic.AppVersionKubeAddon{} + kubeAddonOperator := &tectonic.KubeAddonOperator{} + roleAdmin := &tectonic.RoleAdmin{} + roleUser := &tectonic.RoleUser{} + bindingAdmin := &tectonic.BindingAdmin{} + pullTectonicSystem := &tectonic.PullTectonicSystem{} + cloudCredsSecret := &tectonic.CloudCredsSecret{} + roleCloudCredsSecretReader := &tectonic.RoleCloudCredsSecretReader{} + dependencies.Get( + bindingDiscovery, + appVersionKubeAddon, + kubeAddonOperator, + roleAdmin, + roleUser, + bindingAdmin, + pullTectonicSystem, + cloudCredsSecret, + roleCloudCredsSecretReader) assetData := map[string][]byte{ - "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_binding-discovery.yaml": []byte(bindingDiscovery.Files()[0].Data), + "99_kube-addon-00-appversion.yaml": []byte(appVersionKubeAddon.Files()[0].Data), + "99_kube-addon-01-operator.yaml": applyTemplateData(kubeAddonOperator.Files()[0].Data, templateData), "99_openshift-cluster-api_cluster.yaml": clusterk8sio.Raw, "99_openshift-cluster-api_master-machines.yaml": master.MachinesRaw, "99_openshift-cluster-api_master-user-data-secret.yaml": master.UserDataSecretRaw, "99_openshift-cluster-api_worker-machineset.yaml": worker.MachineSetRaw, "99_openshift-cluster-api_worker-user-data-secret.yaml": worker.UserDataSecretRaw, - "99_role-admin.yaml": []byte(content.RoleAdmin), - "99_role-user.yaml": []byte(content.RoleUser), - "99_tectonic-system-00-binding-admin.yaml": []byte(content.BindingAdmin), - "99_tectonic-system-02-pull.json": applyTemplateData(content.PullTectonicSystem, templateData), + "99_role-admin.yaml": []byte(roleAdmin.Files()[0].Data), + "99_role-user.yaml": []byte(roleUser.Files()[0].Data), + "99_tectonic-system-00-binding-admin.yaml": []byte(bindingAdmin.Files()[0].Data), + "99_tectonic-system-02-pull.json": applyTemplateData(pullTectonicSystem.Files()[0].Data, templateData), } switch platform { case "aws", "openstack": - assetData["99_cloud-creds-secret.yaml"] = applyTemplateData(content.CloudCredsSecret, templateData) - assetData["99_role-cloud-creds-secret-reader.yaml"] = applyTemplateData(content.RoleCloudCredsSecretReader, templateData) + assetData["99_cloud-creds-secret.yaml"] = applyTemplateData(cloudCredsSecret.Files()[0].Data, templateData) + assetData["99_role-cloud-creds-secret-reader.yaml"] = applyTemplateData(roleCloudCredsSecretReader.Files()[0].Data, templateData) } // addon goes to openshift system diff --git a/pkg/asset/templates/content/bootkube/01-tectonic-namespace.go b/pkg/asset/templates/content/bootkube/01-tectonic-namespace.go new file mode 100644 index 00000000000..5db0a24cebf --- /dev/null +++ b/pkg/asset/templates/content/bootkube/01-tectonic-namespace.go @@ -0,0 +1,66 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + tectonicNamespaceFileName = "01-tectonic-namespace.yaml" +) + +var _ asset.WritableAsset = (*TectonicNamespace)(nil) + +// TectonicNamespace is the constant to represent contents of Tectonic_Namespace.yaml file +type TectonicNamespace struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *TectonicNamespace) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *TectonicNamespace) Name() string { + return "TectonicNamespace" +} + +// Generate generates the actual files by this asset +func (t *TectonicNamespace) Generate(parents asset.Parents) error { + t.fileName = tectonicNamespaceFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *TectonicNamespace) Files() []*asset.File { + // Files returns the files generated by the asset. + return t.FileList +} + +// Load returns the asset from disk. +func (t *TectonicNamespace) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, tectonicNamespaceFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/03-openshift-web-console-namespace.go b/pkg/asset/templates/content/bootkube/03-openshift-web-console-namespace.go new file mode 100644 index 00000000000..85cf2d1fcc7 --- /dev/null +++ b/pkg/asset/templates/content/bootkube/03-openshift-web-console-namespace.go @@ -0,0 +1,65 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + openshiftWebConsoleNamespaceFileName = "03-openshift-web-console-namespace.yaml" +) + +var _ asset.WritableAsset = (*OpenshiftWebConsoleNamespace)(nil) + +// OpenshiftWebConsoleNamespace is the constant to represent contents of Openshift_WebConsoleNamespace.yaml file +type OpenshiftWebConsoleNamespace struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *OpenshiftWebConsoleNamespace) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *OpenshiftWebConsoleNamespace) Name() string { + return "OpenshiftWebConsoleNamespace" +} + +// Generate generates the actual files by this asset +func (t *OpenshiftWebConsoleNamespace) Generate(parents asset.Parents) error { + t.fileName = openshiftWebConsoleNamespaceFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *OpenshiftWebConsoleNamespace) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *OpenshiftWebConsoleNamespace) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, openshiftWebConsoleNamespaceFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/04-openshift-machine-config-operator.go b/pkg/asset/templates/content/bootkube/04-openshift-machine-config-operator.go new file mode 100644 index 00000000000..3b5676ddc52 --- /dev/null +++ b/pkg/asset/templates/content/bootkube/04-openshift-machine-config-operator.go @@ -0,0 +1,65 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + openshiftMachineConfigOperatorFileName = "04-openshift-machine-config-operator.yaml" +) + +var _ asset.WritableAsset = (*OpenshiftMachineConfigOperator)(nil) + +// OpenshiftMachineConfigOperator is the constant to represent contents of Openshift_MachineConfigOperator.yaml file +type OpenshiftMachineConfigOperator struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *OpenshiftMachineConfigOperator) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *OpenshiftMachineConfigOperator) Name() string { + return "OpenshiftMachineConfigOperator" +} + +// Generate generates the actual files by this asset +func (t *OpenshiftMachineConfigOperator) Generate(parents asset.Parents) error { + t.fileName = openshiftMachineConfigOperatorFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *OpenshiftMachineConfigOperator) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *OpenshiftMachineConfigOperator) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, openshiftMachineConfigOperatorFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/05-openshift-cluster-api-namespace.go b/pkg/asset/templates/content/bootkube/05-openshift-cluster-api-namespace.go new file mode 100644 index 00000000000..ff83d97094f --- /dev/null +++ b/pkg/asset/templates/content/bootkube/05-openshift-cluster-api-namespace.go @@ -0,0 +1,65 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + openshiftClusterAPINamespaceFileName = "05-openshift-cluster-api-namespace.yaml" +) + +var _ asset.WritableAsset = (*OpenshiftClusterAPINamespace)(nil) + +// OpenshiftClusterAPINamespace is the constant to represent contents of Openshift_ClusterApiNamespace.yaml file +type OpenshiftClusterAPINamespace struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *OpenshiftClusterAPINamespace) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *OpenshiftClusterAPINamespace) Name() string { + return "OpenshiftClusterAPINamespace" +} + +// Generate generates the actual files by this asset +func (t *OpenshiftClusterAPINamespace) Generate(parents asset.Parents) error { + t.fileName = openshiftClusterAPINamespaceFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *OpenshiftClusterAPINamespace) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *OpenshiftClusterAPINamespace) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, openshiftClusterAPINamespaceFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/09-openshift-service-cert-signer-namespace.go b/pkg/asset/templates/content/bootkube/09-openshift-service-cert-signer-namespace.go new file mode 100644 index 00000000000..a5d9650846b --- /dev/null +++ b/pkg/asset/templates/content/bootkube/09-openshift-service-cert-signer-namespace.go @@ -0,0 +1,65 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + openshiftServiceCertSignerNamespaceFileName = "09-openshift-service-cert-signer-namespace.yaml" +) + +var _ asset.WritableAsset = (*OpenshiftServiceCertSignerNamespace)(nil) + +// OpenshiftServiceCertSignerNamespace is the constant to represent the contents of 09-openshift-service-signer-namespace.yaml +type OpenshiftServiceCertSignerNamespace struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *OpenshiftServiceCertSignerNamespace) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *OpenshiftServiceCertSignerNamespace) Name() string { + return "OpenshiftServiceCertSignerNamespace" +} + +// Generate generates the actual files by this asset +func (t *OpenshiftServiceCertSignerNamespace) Generate(parents asset.Parents) error { + t.fileName = openshiftServiceCertSignerNamespaceFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *OpenshiftServiceCertSignerNamespace) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *OpenshiftServiceCertSignerNamespace) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, openshiftServiceCertSignerNamespaceFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/app-version-kind.go b/pkg/asset/templates/content/bootkube/app-version-kind.go new file mode 100644 index 00000000000..3f59df42530 --- /dev/null +++ b/pkg/asset/templates/content/bootkube/app-version-kind.go @@ -0,0 +1,65 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + appVersionKindFileName = "app-version-kind.yaml" +) + +var _ asset.WritableAsset = (*AppVersionKind)(nil) + +// AppVersionKind is the constant to represent contents of App_VersionKind.yaml file +type AppVersionKind struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *AppVersionKind) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *AppVersionKind) Name() string { + return "AppVersionKind" +} + +// Generate generates the actual files by this asset +func (t *AppVersionKind) Generate(parents asset.Parents) error { + t.fileName = appVersionKindFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *AppVersionKind) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *AppVersionKind) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, appVersionKindFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/app-version-tectonic-network.go b/pkg/asset/templates/content/bootkube/app-version-tectonic-network.go new file mode 100644 index 00000000000..44a22452ea5 --- /dev/null +++ b/pkg/asset/templates/content/bootkube/app-version-tectonic-network.go @@ -0,0 +1,65 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + appVersionTectonicNetworkFileName = "app-version-tectonic-network.yaml" +) + +var _ asset.WritableAsset = (*AppVersionTectonicNetwork)(nil) + +// AppVersionTectonicNetwork is the constant to represent contents of App_VersionTectonicNetwork.yaml file +type AppVersionTectonicNetwork struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *AppVersionTectonicNetwork) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *AppVersionTectonicNetwork) Name() string { + return "AppVersionTectonicNetwork" +} + +// Generate generates the actual files by this asset +func (t *AppVersionTectonicNetwork) Generate(parents asset.Parents) error { + t.fileName = appVersionTectonicNetworkFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *AppVersionTectonicNetwork) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *AppVersionTectonicNetwork) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, appVersionTectonicNetworkFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/cvo-overrides.go b/pkg/asset/templates/content/bootkube/cvo-overrides.go new file mode 100644 index 00000000000..3e29b3ae7fe --- /dev/null +++ b/pkg/asset/templates/content/bootkube/cvo-overrides.go @@ -0,0 +1,68 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + cVOOverridesFileName = "cvo-overrides.yaml.template" +) + +var _ asset.WritableAsset = (*CVOOverrides)(nil) + +// CVOOverrides is the constant to represent contents of cvo-override.yaml.template file +// This is a gate to prevent CVO from installing these operators which is conflicting +// with already owned resources by tectonic-operators. +// This files can be dropped when the overrides list becomes empty. +type CVOOverrides struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *CVOOverrides) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *CVOOverrides) Name() string { + return "CVOOverrides" +} + +// Generate generates the actual files by this asset +func (t *CVOOverrides) Generate(parents asset.Parents) error { + t.fileName = cVOOverridesFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *CVOOverrides) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *CVOOverrides) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, cVOOverridesFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/etcd-service-endpoints.go b/pkg/asset/templates/content/bootkube/etcd-service-endpoints.go new file mode 100644 index 00000000000..b9db7a3c4b7 --- /dev/null +++ b/pkg/asset/templates/content/bootkube/etcd-service-endpoints.go @@ -0,0 +1,65 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + etcdServiceEndpointsKubeSystemFileName = "etcd-service-endpoints.yaml.template" +) + +var _ asset.WritableAsset = (*EtcdServiceEndpointsKubeSystem)(nil) + +// EtcdServiceEndpointsKubeSystem is the constant to represent contents of etcd-service-endpoints.yaml.template file. +type EtcdServiceEndpointsKubeSystem struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *EtcdServiceEndpointsKubeSystem) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *EtcdServiceEndpointsKubeSystem) Name() string { + return "EtcdServiceEndpointsKubeSystem" +} + +// Generate generates the actual files by this asset +func (t *EtcdServiceEndpointsKubeSystem) Generate(parents asset.Parents) error { + t.fileName = etcdServiceEndpointsKubeSystemFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *EtcdServiceEndpointsKubeSystem) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *EtcdServiceEndpointsKubeSystem) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, etcdServiceEndpointsKubeSystemFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/etcd-service.go b/pkg/asset/templates/content/bootkube/etcd-service.go new file mode 100644 index 00000000000..90fdcdae699 --- /dev/null +++ b/pkg/asset/templates/content/bootkube/etcd-service.go @@ -0,0 +1,65 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + etcdServiceKubeSystemFileName = "etcd-service.yaml" +) + +var _ asset.WritableAsset = (*EtcdServiceKubeSystem)(nil) + +// EtcdServiceKubeSystem is the constant to represent contents of etcd-service.yaml file +type EtcdServiceKubeSystem struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *EtcdServiceKubeSystem) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *EtcdServiceKubeSystem) Name() string { + return "EtcdServiceKubeSystem" +} + +// Generate generates the actual files by this asset +func (t *EtcdServiceKubeSystem) Generate(parents asset.Parents) error { + t.fileName = etcdServiceKubeSystemFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *EtcdServiceKubeSystem) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *EtcdServiceKubeSystem) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, etcdServiceKubeSystemFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/kube-cloud-config.go b/pkg/asset/templates/content/bootkube/kube-cloud-config.go new file mode 100644 index 00000000000..1b5e649e486 --- /dev/null +++ b/pkg/asset/templates/content/bootkube/kube-cloud-config.go @@ -0,0 +1,65 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + kubeCloudConfigFileName = "kube-cloud-config.yaml" +) + +var _ asset.WritableAsset = (*KubeCloudConfig)(nil) + +// KubeCloudConfig is the constant to represent contents of kube_cloudconfig.yaml file +type KubeCloudConfig struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *KubeCloudConfig) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *KubeCloudConfig) Name() string { + return "KubeCloudConfig" +} + +// Generate generates the actual files by this asset +func (t *KubeCloudConfig) Generate(parents asset.Parents) error { + t.fileName = kubeCloudConfigFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *KubeCloudConfig) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *KubeCloudConfig) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, kubeCloudConfigFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/kube-system-configmap-etcd-serving-ca.go b/pkg/asset/templates/content/bootkube/kube-system-configmap-etcd-serving-ca.go new file mode 100644 index 00000000000..0d152ddba95 --- /dev/null +++ b/pkg/asset/templates/content/bootkube/kube-system-configmap-etcd-serving-ca.go @@ -0,0 +1,65 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + kubeSystemConfigmapEtcdServingCAFileName = "kube-system-configmap-etcd-serving-ca.yaml.template" +) + +var _ asset.WritableAsset = (*KubeSystemConfigmapEtcdServingCA)(nil) + +// KubeSystemConfigmapEtcdServingCA is the constant to represent contents of kube-system-configmap-etcd-serving-ca.yaml.template file. +type KubeSystemConfigmapEtcdServingCA struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *KubeSystemConfigmapEtcdServingCA) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *KubeSystemConfigmapEtcdServingCA) Name() string { + return "KubeSystemConfigmapEtcdServingCA" +} + +// Generate generates the actual files by this asset +func (t *KubeSystemConfigmapEtcdServingCA) Generate(parents asset.Parents) error { + t.fileName = kubeSystemConfigmapEtcdServingCAFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *KubeSystemConfigmapEtcdServingCA) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *KubeSystemConfigmapEtcdServingCA) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, kubeSystemConfigmapEtcdServingCAFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/kube-system-configmap-root-ca.go b/pkg/asset/templates/content/bootkube/kube-system-configmap-root-ca.go new file mode 100644 index 00000000000..99a5b70a751 --- /dev/null +++ b/pkg/asset/templates/content/bootkube/kube-system-configmap-root-ca.go @@ -0,0 +1,65 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + kubeSystemConfigmapRootCAFileName = "kube-system-configmap-root-ca.yaml.template" +) + +var _ asset.WritableAsset = (*KubeSystemConfigmapRootCA)(nil) + +// KubeSystemConfigmapRootCA is the constant to represent contents of kube-system-configmap-root-ca.yaml.template file. +type KubeSystemConfigmapRootCA struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *KubeSystemConfigmapRootCA) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *KubeSystemConfigmapRootCA) Name() string { + return "KubeSystemConfigmapRootCA" +} + +// Generate generates the actual files by this asset +func (t *KubeSystemConfigmapRootCA) Generate(parents asset.Parents) error { + t.fileName = kubeSystemConfigmapRootCAFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *KubeSystemConfigmapRootCA) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *KubeSystemConfigmapRootCA) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, kubeSystemConfigmapRootCAFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/kube-system-secret-etcd-client.go b/pkg/asset/templates/content/bootkube/kube-system-secret-etcd-client.go new file mode 100644 index 00000000000..3ba3af00f4e --- /dev/null +++ b/pkg/asset/templates/content/bootkube/kube-system-secret-etcd-client.go @@ -0,0 +1,65 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + kubeSystemSecretEtcdClientFileName = "kube-system-secret-etcd-client.yaml.template" +) + +var _ asset.WritableAsset = (*KubeSystemSecretEtcdClient)(nil) + +// KubeSystemSecretEtcdClient is the constant to represent contents of kube-system-secret-etcd-client.yaml.template file. +type KubeSystemSecretEtcdClient struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *KubeSystemSecretEtcdClient) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *KubeSystemSecretEtcdClient) Name() string { + return "KubeSystemSecretEtcdClient" +} + +// Generate generates the actual files by this asset +func (t *KubeSystemSecretEtcdClient) Generate(parents asset.Parents) error { + t.fileName = kubeSystemSecretEtcdClientFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *KubeSystemSecretEtcdClient) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *KubeSystemSecretEtcdClient) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, kubeSystemSecretEtcdClientFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/legacy-cvo-overrides.go b/pkg/asset/templates/content/bootkube/legacy-cvo-overrides.go new file mode 100644 index 00000000000..f5968813fdf --- /dev/null +++ b/pkg/asset/templates/content/bootkube/legacy-cvo-overrides.go @@ -0,0 +1,68 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + legacyCVOOverridesFileName = "legacy-cvo-overrides.yaml.template" +) + +var _ asset.WritableAsset = (*LegacyCVOOverrides)(nil) + +// LegacyCVOOverrides is the constant to represent contents of legacy-cvo-override.yaml.template file +// This is a gate to prevent CVO from installing these operators which is conflicting +// with already owned resources by tectonic-operators. +// This files can be dropped when the overrides list becomes empty. +type LegacyCVOOverrides struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *LegacyCVOOverrides) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *LegacyCVOOverrides) Name() string { + return "LegacyCVOOverrides" +} + +// Generate generates the actual files by this asset +func (t *LegacyCVOOverrides) Generate(parents asset.Parents) error { + t.fileName = legacyCVOOverridesFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *LegacyCVOOverrides) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *LegacyCVOOverrides) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, legacyCVOOverridesFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/machine-config-server-tls-secret.go b/pkg/asset/templates/content/bootkube/machine-config-server-tls-secret.go new file mode 100644 index 00000000000..f5403bbdd6e --- /dev/null +++ b/pkg/asset/templates/content/bootkube/machine-config-server-tls-secret.go @@ -0,0 +1,65 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + machineConfigServerTLSSecretFileName = "machine-config-server-tls-secret.yaml.template" +) + +var _ asset.WritableAsset = (*MachineConfigServerTLSSecret)(nil) + +// MachineConfigServerTLSSecret is the constant to represent contents of machine_configservertlssecret.yaml.template file +type MachineConfigServerTLSSecret struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *MachineConfigServerTLSSecret) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *MachineConfigServerTLSSecret) Name() string { + return "MachineConfigServerTLSSecret" +} + +// Generate generates the actual files by this asset +func (t *MachineConfigServerTLSSecret) Generate(parents asset.Parents) error { + t.fileName = machineConfigServerTLSSecretFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *MachineConfigServerTLSSecret) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *MachineConfigServerTLSSecret) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, machineConfigServerTLSSecretFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/openshift-service-cert-signer-ca-secret.go b/pkg/asset/templates/content/bootkube/openshift-service-cert-signer-ca-secret.go new file mode 100644 index 00000000000..ac84b473ddf --- /dev/null +++ b/pkg/asset/templates/content/bootkube/openshift-service-cert-signer-ca-secret.go @@ -0,0 +1,65 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + openshiftServiceCertSignerSecretFileName = "openshift-service-cert-signer-ca-secret.yaml.template" +) + +var _ asset.WritableAsset = (*OpenshiftServiceCertSignerSecret)(nil) + +// OpenshiftServiceCertSignerSecret is the constant to represent the contents of openshift-service-signer-secret.yaml.template +type OpenshiftServiceCertSignerSecret struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *OpenshiftServiceCertSignerSecret) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *OpenshiftServiceCertSignerSecret) Name() string { + return "OpenshiftServiceCertSignerSecret" +} + +// Generate generates the actual files by this asset +func (t *OpenshiftServiceCertSignerSecret) Generate(parents asset.Parents) error { + t.fileName = openshiftServiceCertSignerSecretFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *OpenshiftServiceCertSignerSecret) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *OpenshiftServiceCertSignerSecret) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, openshiftServiceCertSignerSecretFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/pull.go b/pkg/asset/templates/content/bootkube/pull.go new file mode 100644 index 00000000000..02c5701bc2c --- /dev/null +++ b/pkg/asset/templates/content/bootkube/pull.go @@ -0,0 +1,65 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + pullFileName = "pull.yaml.template" +) + +var _ asset.WritableAsset = (*Pull)(nil) + +// Pull is the constant to represent contents of pull.yaml.template file +type Pull struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *Pull) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *Pull) Name() string { + return "Pull" +} + +// Generate generates the actual files by this asset +func (t *Pull) Generate(parents asset.Parents) error { + t.fileName = pullFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *Pull) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *Pull) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, pullFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/bootkube/tectonic-network-operator.go b/pkg/asset/templates/content/bootkube/tectonic-network-operator.go new file mode 100644 index 00000000000..5e98aece40a --- /dev/null +++ b/pkg/asset/templates/content/bootkube/tectonic-network-operator.go @@ -0,0 +1,65 @@ +package bootkube + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + tectonicNetworkOperatorFileName = "tectonic-network-operator.yaml.template" +) + +var _ asset.WritableAsset = (*TectonicNetworkOperator)(nil) + +// TectonicNetworkOperator represents the template variable for tectonic-network-operator.yaml.template file +type TectonicNetworkOperator struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *TectonicNetworkOperator) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *TectonicNetworkOperator) Name() string { + return "TectonicNetworkOperator" +} + +// Generate generates the actual files by this asset +func (t *TectonicNetworkOperator) Generate(parents asset.Parents) error { + t.fileName = tectonicNetworkOperatorFileName + data, err := content.GetBootkubeTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *TectonicNetworkOperator) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *TectonicNetworkOperator) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, tectonicNetworkOperatorFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/helper.go b/pkg/asset/templates/content/helper.go new file mode 100644 index 00000000000..27dd210ae55 --- /dev/null +++ b/pkg/asset/templates/content/helper.go @@ -0,0 +1,36 @@ +package content + +import ( + "io/ioutil" + "path" + + "github.com/openshift/installer/data" +) + +const ( + // TemplateDir is the target directory for all template assets' files + TemplateDir = "templates" + bootkubeDataDir = "manifests/bootkube/" + tectonicDataDir = "manifests/tectonic/" +) + +// GetBootkubeTemplate returns the contents of the file in bootkube data dir +func GetBootkubeTemplate(uri string) ([]byte, error) { + return getFileContents(path.Join(bootkubeDataDir, uri)) +} + +// GetTectonicTemplate returns the contents of the file in tectonic data dir +func GetTectonicTemplate(uri string) ([]byte, error) { + return getFileContents(path.Join(tectonicDataDir, uri)) +} + +// getFileContents the content of the given URI, assuming that it's a file +func getFileContents(uri string) ([]byte, error) { + file, err := data.Assets.Open(uri) + if err != nil { + return []byte{}, err + } + defer file.Close() + + return ioutil.ReadAll(file) +} diff --git a/pkg/asset/templates/content/tectonic/binding-discovery.go b/pkg/asset/templates/content/tectonic/binding-discovery.go new file mode 100644 index 00000000000..7643525f1ec --- /dev/null +++ b/pkg/asset/templates/content/tectonic/binding-discovery.go @@ -0,0 +1,65 @@ +package tectonic + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + bindingDiscoveryFileName = "binding-discovery.yaml" +) + +var _ asset.WritableAsset = (*BindingDiscovery)(nil) + +// BindingDiscovery is the variable/constant representing the contents of the respective file +type BindingDiscovery struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *BindingDiscovery) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *BindingDiscovery) Name() string { + return "BindingDiscovery" +} + +// Generate generates the actual files by this asset +func (t *BindingDiscovery) Generate(parents asset.Parents) error { + t.fileName = bindingDiscoveryFileName + data, err := content.GetTectonicTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *BindingDiscovery) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *BindingDiscovery) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, bindingDiscoveryFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/tectonic/cloud-creds-secret.go b/pkg/asset/templates/content/tectonic/cloud-creds-secret.go new file mode 100644 index 00000000000..cb0149228a1 --- /dev/null +++ b/pkg/asset/templates/content/tectonic/cloud-creds-secret.go @@ -0,0 +1,65 @@ +package tectonic + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + cloudCredsSecretFileName = "cloud-creds-secret.yaml.template" +) + +var _ asset.WritableAsset = (*CloudCredsSecret)(nil) + +// CloudCredsSecret is the constant to represent contents of corresponding yaml file +type CloudCredsSecret struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *CloudCredsSecret) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *CloudCredsSecret) Name() string { + return "CloudCredsSecret" +} + +// Generate generates the actual files by this asset +func (t *CloudCredsSecret) Generate(parents asset.Parents) error { + t.fileName = cloudCredsSecretFileName + data, err := content.GetTectonicTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *CloudCredsSecret) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *CloudCredsSecret) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, cloudCredsSecretFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/tectonic/kube-addon-00-appversion.go b/pkg/asset/templates/content/tectonic/kube-addon-00-appversion.go new file mode 100644 index 00000000000..bb5e890662d --- /dev/null +++ b/pkg/asset/templates/content/tectonic/kube-addon-00-appversion.go @@ -0,0 +1,65 @@ +package tectonic + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + appVersionKubeAddonFileName = "kube-addon-00-appversion.yaml" +) + +var _ asset.WritableAsset = (*AppVersionKubeAddon)(nil) + +// AppVersionKubeAddon is the variable/constant representing the contents of the respective file +type AppVersionKubeAddon struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *AppVersionKubeAddon) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *AppVersionKubeAddon) Name() string { + return "AppVersionKubeAddon" +} + +// Generate generates the actual files by this asset +func (t *AppVersionKubeAddon) Generate(parents asset.Parents) error { + t.fileName = appVersionKubeAddonFileName + data, err := content.GetTectonicTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *AppVersionKubeAddon) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *AppVersionKubeAddon) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, appVersionKubeAddonFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/tectonic/kube-addon-01-operator.go b/pkg/asset/templates/content/tectonic/kube-addon-01-operator.go new file mode 100644 index 00000000000..35b03178894 --- /dev/null +++ b/pkg/asset/templates/content/tectonic/kube-addon-01-operator.go @@ -0,0 +1,65 @@ +package tectonic + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + kubeAddonOperatorFileName = "kube-addon-01-operator.yaml.template" +) + +var _ asset.WritableAsset = (*KubeAddonOperator)(nil) + +// KubeAddonOperator is the variable/constant representing the contents of the respective file +type KubeAddonOperator struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *KubeAddonOperator) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *KubeAddonOperator) Name() string { + return "KubeAddonOperator" +} + +// Generate generates the actual files by this asset +func (t *KubeAddonOperator) Generate(parents asset.Parents) error { + t.fileName = kubeAddonOperatorFileName + data, err := content.GetTectonicTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *KubeAddonOperator) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *KubeAddonOperator) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, kubeAddonOperatorFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/tectonic/role-admin.go b/pkg/asset/templates/content/tectonic/role-admin.go new file mode 100644 index 00000000000..9c2cc068e44 --- /dev/null +++ b/pkg/asset/templates/content/tectonic/role-admin.go @@ -0,0 +1,65 @@ +package tectonic + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + roleAdminFileName = "role-admin.yaml" +) + +var _ asset.WritableAsset = (*RoleAdmin)(nil) + +// RoleAdmin is the variable/constant representing the contents of the respective file +type RoleAdmin struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *RoleAdmin) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *RoleAdmin) Name() string { + return "RoleAdmin" +} + +// Generate generates the actual files by this asset +func (t *RoleAdmin) Generate(parents asset.Parents) error { + t.fileName = roleAdminFileName + data, err := content.GetTectonicTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *RoleAdmin) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *RoleAdmin) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, roleAdminFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/tectonic/role-cloud-creds-secret-reader.go b/pkg/asset/templates/content/tectonic/role-cloud-creds-secret-reader.go new file mode 100644 index 00000000000..e3ccbdcd159 --- /dev/null +++ b/pkg/asset/templates/content/tectonic/role-cloud-creds-secret-reader.go @@ -0,0 +1,65 @@ +package tectonic + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + roleCloudCredsSecretReaderFileName = "role-cloud-creds-secret-reader.yaml.template" +) + +var _ asset.WritableAsset = (*RoleCloudCredsSecretReader)(nil) + +// RoleCloudCredsSecretReader is the variable to represent contents of corresponding file +type RoleCloudCredsSecretReader struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *RoleCloudCredsSecretReader) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *RoleCloudCredsSecretReader) Name() string { + return "RoleCloudCredsSecretReader" +} + +// Generate generates the actual files by this asset +func (t *RoleCloudCredsSecretReader) Generate(parents asset.Parents) error { + t.fileName = roleCloudCredsSecretReaderFileName + data, err := content.GetTectonicTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *RoleCloudCredsSecretReader) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *RoleCloudCredsSecretReader) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, roleCloudCredsSecretReaderFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/tectonic/role-user.go b/pkg/asset/templates/content/tectonic/role-user.go new file mode 100644 index 00000000000..3c2b824afbd --- /dev/null +++ b/pkg/asset/templates/content/tectonic/role-user.go @@ -0,0 +1,65 @@ +package tectonic + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + roleUserFileName = "role-user.yaml" +) + +var _ asset.WritableAsset = (*RoleUser)(nil) + +// RoleUser is the variable/constant representing the contents of the respective file +type RoleUser struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *RoleUser) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *RoleUser) Name() string { + return "RoleUser" +} + +// Generate generates the actual files by this asset +func (t *RoleUser) Generate(parents asset.Parents) error { + t.fileName = roleUserFileName + data, err := content.GetTectonicTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *RoleUser) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *RoleUser) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, roleUserFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/tectonic/tectonic-system-00-binding-admin.go b/pkg/asset/templates/content/tectonic/tectonic-system-00-binding-admin.go new file mode 100644 index 00000000000..c471d1ec36b --- /dev/null +++ b/pkg/asset/templates/content/tectonic/tectonic-system-00-binding-admin.go @@ -0,0 +1,65 @@ +package tectonic + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + bindingAdminFileName = "tectonic-system-00-binding-admin.yaml" +) + +var _ asset.WritableAsset = (*BindingAdmin)(nil) + +// BindingAdmin is the variable/constant representing the contents of the respective file +type BindingAdmin struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *BindingAdmin) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *BindingAdmin) Name() string { + return "BindingAdmin" +} + +// Generate generates the actual files by this asset +func (t *BindingAdmin) Generate(parents asset.Parents) error { + t.fileName = bindingAdminFileName + data, err := content.GetTectonicTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *BindingAdmin) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *BindingAdmin) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, bindingAdminFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/content/tectonic/tectonic-system-02-pull.go b/pkg/asset/templates/content/tectonic/tectonic-system-02-pull.go new file mode 100644 index 00000000000..14af9ac805c --- /dev/null +++ b/pkg/asset/templates/content/tectonic/tectonic-system-02-pull.go @@ -0,0 +1,65 @@ +package tectonic + +import ( + "os" + "path/filepath" + + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content" +) + +const ( + pullTectonicSystemFileName = "tectonic-system-02-pull.yaml.template" +) + +var _ asset.WritableAsset = (*PullTectonicSystem)(nil) + +// PullTectonicSystem is the variable/constant representing the contents of the respective file +type PullTectonicSystem struct { + fileName string + FileList []*asset.File +} + +// Dependencies returns all of the dependencies directly needed by the asset +func (t *PullTectonicSystem) Dependencies() []asset.Asset { + return []asset.Asset{} +} + +// Name returns the human-friendly name of the asset. +func (t *PullTectonicSystem) Name() string { + return "PullTectonicSystem" +} + +// Generate generates the actual files by this asset +func (t *PullTectonicSystem) Generate(parents asset.Parents) error { + t.fileName = pullTectonicSystemFileName + data, err := content.GetTectonicTemplate(t.fileName) + if err != nil { + return err + } + t.FileList = []*asset.File{ + { + Filename: filepath.Join(content.TemplateDir, t.fileName), + Data: []byte(data), + }, + } + return nil +} + +// Files returns the files generated by the asset. +func (t *PullTectonicSystem) Files() []*asset.File { + return t.FileList +} + +// Load returns the asset from disk. +func (t *PullTectonicSystem) Load(f asset.FileFetcher) (bool, error) { + file, err := f.FetchByName(filepath.Join(content.TemplateDir, pullTectonicSystemFileName)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + t.FileList = []*asset.File{file} + return true, nil +} diff --git a/pkg/asset/templates/templates.go b/pkg/asset/templates/templates.go new file mode 100644 index 00000000000..8441b4a2fb3 --- /dev/null +++ b/pkg/asset/templates/templates.go @@ -0,0 +1,161 @@ +// Package templates deals with creating template assets that will be used by other assets +package templates + +import ( + "github.com/openshift/installer/pkg/asset" + "github.com/openshift/installer/pkg/asset/templates/content/bootkube" + "github.com/openshift/installer/pkg/asset/templates/content/tectonic" +) + +var _ asset.WritableAsset = (*Templates)(nil) + +// Templates generates the dependent unrendered template files +type Templates struct { + FileList []*asset.File +} + +// Name returns a human friendly name for the templates asset +func (m *Templates) Name() string { + return "Common Templates" +} + +// Dependencies returns all of the dependencies directly needed by a +// Templates asset. +func (m *Templates) Dependencies() []asset.Asset { + return []asset.Asset{ + &bootkube.KubeCloudConfig{}, + &bootkube.MachineConfigServerTLSSecret{}, + &bootkube.OpenshiftServiceCertSignerSecret{}, + &bootkube.Pull{}, + &bootkube.TectonicNetworkOperator{}, + &bootkube.CVOOverrides{}, + &bootkube.LegacyCVOOverrides{}, + &bootkube.EtcdServiceEndpointsKubeSystem{}, + &bootkube.KubeSystemConfigmapEtcdServingCA{}, + &bootkube.KubeSystemConfigmapRootCA{}, + &bootkube.KubeSystemSecretEtcdClient{}, + &bootkube.TectonicNamespace{}, + &bootkube.OpenshiftWebConsoleNamespace{}, + &bootkube.OpenshiftMachineConfigOperator{}, + &bootkube.OpenshiftClusterAPINamespace{}, + &bootkube.OpenshiftServiceCertSignerNamespace{}, + &bootkube.AppVersionKind{}, + &bootkube.AppVersionTectonicNetwork{}, + &bootkube.EtcdServiceKubeSystem{}, + &tectonic.BindingDiscovery{}, + &tectonic.AppVersionKubeAddon{}, + &tectonic.KubeAddonOperator{}, + &tectonic.RoleAdmin{}, + &tectonic.RoleUser{}, + &tectonic.BindingAdmin{}, + &tectonic.PullTectonicSystem{}, + &tectonic.CloudCredsSecret{}, + &tectonic.RoleCloudCredsSecretReader{}, + } +} + +// Generate generates the respective operator config.yml files +func (m *Templates) Generate(dependencies asset.Parents) error { + kubeCloudConfig := &bootkube.KubeCloudConfig{} + machineConfigServerTLSSecret := &bootkube.MachineConfigServerTLSSecret{} + openshiftServiceCertSignerSecret := &bootkube.OpenshiftServiceCertSignerSecret{} + pull := &bootkube.Pull{} + tectonicNetworkOperator := &bootkube.TectonicNetworkOperator{} + cVOOverrides := &bootkube.CVOOverrides{} + legacyCVOOverrides := &bootkube.LegacyCVOOverrides{} + etcdServiceEndpointsKubeSystem := &bootkube.EtcdServiceEndpointsKubeSystem{} + kubeSystemConfigmapEtcdServingCA := &bootkube.KubeSystemConfigmapEtcdServingCA{} + kubeSystemConfigmapRootCA := &bootkube.KubeSystemConfigmapRootCA{} + kubeSystemSecretEtcdClient := &bootkube.KubeSystemSecretEtcdClient{} + tectonicNamespace := &bootkube.TectonicNamespace{} + openshiftWebConsoleNamespace := &bootkube.OpenshiftWebConsoleNamespace{} + openshiftMachineConfigOperator := &bootkube.OpenshiftMachineConfigOperator{} + openshiftClusterAPINamespace := &bootkube.OpenshiftClusterAPINamespace{} + openshiftServiceCertSignerNamespace := &bootkube.OpenshiftServiceCertSignerNamespace{} + appVersionKind := &bootkube.AppVersionKind{} + appVersionTectonicNetwork := &bootkube.AppVersionTectonicNetwork{} + etcdServiceKubeSystem := &bootkube.EtcdServiceKubeSystem{} + + bindingDiscovery := &tectonic.BindingDiscovery{} + appVersionKubeAddon := &tectonic.AppVersionKubeAddon{} + kubeAddonOperator := &tectonic.KubeAddonOperator{} + roleAdmin := &tectonic.RoleAdmin{} + roleUser := &tectonic.RoleUser{} + bindingAdmin := &tectonic.BindingAdmin{} + pullTectonicSystem := &tectonic.PullTectonicSystem{} + cloudCredsSecret := &tectonic.CloudCredsSecret{} + roleCloudCredsSecretReader := &tectonic.RoleCloudCredsSecretReader{} + + dependencies.Get( + kubeCloudConfig, + machineConfigServerTLSSecret, + openshiftServiceCertSignerSecret, + pull, + tectonicNetworkOperator, + cVOOverrides, + legacyCVOOverrides, + etcdServiceEndpointsKubeSystem, + kubeSystemConfigmapEtcdServingCA, + kubeSystemConfigmapRootCA, + kubeSystemSecretEtcdClient, + tectonicNamespace, + openshiftWebConsoleNamespace, + openshiftMachineConfigOperator, + openshiftClusterAPINamespace, + openshiftServiceCertSignerNamespace, + appVersionKind, + appVersionTectonicNetwork, + etcdServiceKubeSystem, + bindingDiscovery, + appVersionKubeAddon, + kubeAddonOperator, + roleAdmin, + roleUser, + bindingAdmin, + pullTectonicSystem, + cloudCredsSecret, + roleCloudCredsSecretReader) + + m.FileList = []*asset.File{} + m.FileList = append(m.FileList, kubeCloudConfig.Files()...) + m.FileList = append(m.FileList, machineConfigServerTLSSecret.Files()...) + m.FileList = append(m.FileList, openshiftServiceCertSignerSecret.Files()...) + m.FileList = append(m.FileList, pull.Files()...) + m.FileList = append(m.FileList, tectonicNetworkOperator.Files()...) + m.FileList = append(m.FileList, cVOOverrides.Files()...) + m.FileList = append(m.FileList, legacyCVOOverrides.Files()...) + m.FileList = append(m.FileList, etcdServiceEndpointsKubeSystem.Files()...) + m.FileList = append(m.FileList, kubeSystemConfigmapEtcdServingCA.Files()...) + m.FileList = append(m.FileList, kubeSystemConfigmapRootCA.Files()...) + m.FileList = append(m.FileList, kubeSystemSecretEtcdClient.Files()...) + m.FileList = append(m.FileList, tectonicNamespace.Files()...) + m.FileList = append(m.FileList, openshiftWebConsoleNamespace.Files()...) + m.FileList = append(m.FileList, openshiftMachineConfigOperator.Files()...) + m.FileList = append(m.FileList, openshiftClusterAPINamespace.Files()...) + m.FileList = append(m.FileList, openshiftServiceCertSignerNamespace.Files()...) + m.FileList = append(m.FileList, appVersionKind.Files()...) + m.FileList = append(m.FileList, appVersionTectonicNetwork.Files()...) + m.FileList = append(m.FileList, etcdServiceKubeSystem.Files()...) + + m.FileList = append(m.FileList, bindingDiscovery.Files()...) + m.FileList = append(m.FileList, appVersionKubeAddon.Files()...) + m.FileList = append(m.FileList, kubeAddonOperator.Files()...) + m.FileList = append(m.FileList, roleAdmin.Files()...) + m.FileList = append(m.FileList, roleUser.Files()...) + m.FileList = append(m.FileList, bindingAdmin.Files()...) + m.FileList = append(m.FileList, pullTectonicSystem.Files()...) + m.FileList = append(m.FileList, cloudCredsSecret.Files()...) + m.FileList = append(m.FileList, roleCloudCredsSecretReader.Files()...) + + return nil +} + +// Files returns the files generated by the asset. +func (m *Templates) Files() []*asset.File { + return m.FileList +} + +// Load returns the manifests asset from disk. +func (m *Templates) Load(f asset.FileFetcher) (bool, error) { + return false, nil +}