forked from openshift/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inject CoreOS stream metadata as configmap via CVO manifest
Split out from openshift#4582 This copies the bits from https://github.com/cgwalters/rhel-coreos-bootimages which builds a ConfigMap out of the stream metadata and injects it into the cluster. We have an `installer` image in the release image today; this adds the "is an operator" label, even though it's not really an operator. We just want the CVO to inject the manifest. Among other important semantics, this will ensure that in-place cluster upgrades that have new pinned CoreOS stream data will have this configmap updated.
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// We want to keep the stream metadata stored "directly" | ||
// in git so it's easy to read and validate. This build | ||
// script is invoked as part of the container build to | ||
// inject the data into a ConfigMap that will be installed | ||
// via CVO manifests into the target cluster, and maintained | ||
// across upgrades. | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
const ( | ||
streamJSON = "data/data/rhcos-stream.json" | ||
dest = "bin/manifests/coreos-bootimages.json" | ||
) | ||
|
||
func run() error { | ||
bootimages, err := ioutil.ReadFile(streamJSON) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cm := &corev1.ConfigMap{ | ||
TypeMeta: metav1.TypeMeta{ | ||
APIVersion: corev1.SchemeGroupVersion.String(), | ||
Kind: "ConfigMap", | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Namespace: "openshift-machine-config-operator", | ||
Name: "coreos-bootimages", | ||
Annotations: map[string]string{ | ||
"include.release.openshift.io/ibm-cloud-managed": "true", | ||
"include.release.openshift.io/self-managed-high-availability": "true", | ||
"include.release.openshift.io/single-node-developer": "true", | ||
}, | ||
}, | ||
Data: map[string]string{ | ||
"releaseVersion": "0.0.1-snapshot", | ||
"stream": string(bootimages), | ||
}, | ||
} | ||
|
||
b, err := json.Marshal(cm) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := os.MkdirAll(filepath.Dir(dest), 0755); err != nil { | ||
return err | ||
} | ||
|
||
err = ioutil.WriteFile(dest, b, 0644) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func main() { | ||
if err := run(); err != nil { | ||
fmt.Fprintf(os.Stderr, "%s\n", err) | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters