Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testsys-launcher: Apply brupop/cert manager manifests #825

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions deploy/testsys-launcher/pkg/manifests.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package pkg

import (
"bytes"
"fmt"
"io"
"net/http"

eks "github.com/aws/aws-cdk-go/awscdk/v2/awseks"
"github.com/aws/jsii-runtime-go"
"gopkg.in/yaml.v3"
)

const (
// The URL of the Cert manager resources required by testsys and/or brupop
certManagerManifestUrl string = "https://github.com/cert-manager/cert-manager/releases/download/v1.8.2/cert-manager.yaml"

// The URL of the Brupop resources to keep the cluster up to date
brupopManifestUrl string = "https://github.com/bottlerocket-os/bottlerocket-update-operator/releases/download/v1.1.0/bottlerocket-update-operator-v1.1.0.yaml"
)

// ApplyCertmanagerManifest applies the cert manager yaml manifests.
// Currently blocked on large manifests not being able to be loaded via Node CDK
// https://github.com/aws/aws-cdk/issues/19165
func ApplyCertmanagerManifest(cluster eks.Cluster) {
certManagerManifests := []*map[string]interface{}{}

res, err := http.Get(certManagerManifestUrl)
if err != nil {
panic(fmt.Sprintf("could not get cert-manager yaml manifest: %v", err))
}
defer res.Body.Close()

body, err := io.ReadAll(res.Body)
if err != nil {
panic(fmt.Sprintf("could not extract body from http request: %v", err))
}

dec := yaml.NewDecoder(bytes.NewReader([]byte(body)))
for {
certManagerYamlChunk := map[string]interface{}{}
if dec.Decode(&certManagerYamlChunk) != nil {
// No more yamls to decode in this multi-yaml-document file.
// So break out to apply all the yaml.
break
}
certManagerManifests = append(certManagerManifests, &certManagerYamlChunk)
}

cluster.AddManifest(jsii.String("cert-manager-yamls"), certManagerManifests...)
}

// ApplyBrupopManifest applies the bottlerocket update operator manifests to the
// cluster to ensure it stays up to date with the latest Bottlerocket version.
// Currently blocked on large manifests not being able to be loaded via Node CDK
// https://github.com/aws/aws-cdk/issues/19165
func ApplyBrupopManifest(cluster eks.Cluster) {
brupopManifests := []*map[string]interface{}{}

res, err := http.Get(brupopManifestUrl)
if err != nil {
panic(fmt.Sprintf("could not get brupop yaml manifest: %v", err))
}
defer res.Body.Close()

body, err := io.ReadAll(res.Body)
if err != nil {
panic(fmt.Sprintf("could not extract body from http request: %v", err))
}

dec := yaml.NewDecoder(bytes.NewReader([]byte(body)))
for {
brupopYamlChunk := map[string]interface{}{}
if dec.Decode(&brupopYamlChunk) != nil {
// No more yamls to decode in this multi-yaml-document file.
// So break out to apply all the yaml.
break
}
brupopManifests = append(brupopManifests, &brupopYamlChunk)
}

cluster.AddManifest(jsii.String("brupop-yamls"), brupopManifests...)
}