-
Notifications
You must be signed in to change notification settings - Fork 217
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
MGMT-1858 - subsystem should use dummy ignition image and not a real one #154
Changes from all commits
dbec399
f529e07
d34ca91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM registry.access.redhat.com/ubi8/ubi:latest | ||
|
||
COPY build/dummy-ignition /dummy-ignition | ||
COPY subsystem/test_kubeconfig /kubeconfig-noingress | ||
CMD ["/dummy-ignition"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"os" | ||
|
||
"github.com/kelseyhightower/envconfig" | ||
"github.com/openshift/assisted-service/pkg/s3wrapper" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
var Options struct { | ||
ClusterID string `envconfig:"CLUSTER_ID"` | ||
S3Config s3wrapper.Config | ||
} | ||
|
||
var dummyFileMap map[string]string = map[string]string{ | ||
"bootstrap.ign": "bootstrap file", | ||
"master.ign": "master file", | ||
"worker.ign": "worker file", | ||
"kubeadmin-password": "kubeadmin-password file", | ||
"kubeconfig-noingress": "kubeconfig-noingress file", | ||
"metadata.json": "metadata file", | ||
"install-config.yaml": "install-config file", | ||
} | ||
|
||
func createDummyFile(name, data string) error { | ||
if name == "kubeconfig-noingress" { | ||
return nil | ||
} | ||
f, err := os.Create(name) | ||
if err != nil { | ||
return err | ||
} | ||
_, err = f.WriteString("data") | ||
f.Close() | ||
return err | ||
} | ||
|
||
func createDummyFiles() error { | ||
for fileName, fileData := range dummyFileMap { | ||
err := createDummyFile(fileName, fileData) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func uploadDummyFiles(s3Client *s3wrapper.S3Client, clusterID string) error { | ||
ctx := context.Background() | ||
for fileName := range dummyFileMap { | ||
err := s3Client.UploadFile(ctx, fileName, clusterID+"/"+fileName) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func main() { | ||
log := logrus.New() | ||
log.SetReportCaller(true) | ||
|
||
log.Println("Starting dummy-ignition") | ||
|
||
err := envconfig.Process("", &Options) | ||
if err != nil { | ||
log.Fatal(err.Error()) | ||
} | ||
|
||
log.Infof("S3 parameters: bucket %s, region %s", Options.S3Config.S3Bucket, Options.S3Config.Region) | ||
|
||
s3Client := s3wrapper.NewS3Client(&Options.S3Config, log) | ||
if s3Client == nil { | ||
log.Fatal("failed to create S3 client, ", err) | ||
} | ||
|
||
err = createDummyFiles() | ||
if err != nil { | ||
log.Fatalf("Failed to create dummy files, err: %s", err) | ||
} | ||
|
||
err = uploadDummyFiles(s3Client, Options.ClusterID) | ||
if err != nil { | ||
log.Fatalf("Failed to upload dummy files, err: %s", err) | ||
} | ||
|
||
log.Println("Dummy ignition finished, Success") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ type Config struct { | |
ServiceBaseURL string `envconfig:"SERVICE_BASE_URL"` | ||
//[TODO] - change the default of Releae image to "", once everyine wll update their environment | ||
ReleaseImage string `envconfig:"OPENSHIFT_INSTALL_RELEASE_IMAGE" default:"quay.io/openshift-release-dev/ocp-release@sha256:eab93b4591699a5a4ff50ad3517892653f04fb840127895bb3609b3cc68f98f3"` | ||
SubsystemRun bool `envconfig:"SUBSYSTEM_RUN"` | ||
} | ||
|
||
func New(log logrus.FieldLogger, kube client.Client, cfg Config) *kubeJob { | ||
|
@@ -302,6 +303,10 @@ func (k *kubeJob) GenerateISO(ctx context.Context, cluster common.Cluster, jobNa | |
func (k *kubeJob) createKubeconfigJob(cluster *common.Cluster, jobName string, cfg []byte, encodedDhcpFileContents string) *batch.Job { | ||
id := cluster.ID | ||
ignitionGeneratorImage := k.Config.IgnitionGenerator | ||
var pullPolicy core.PullPolicy = "Always" | ||
if k.Config.SubsystemRun { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not making the policy as a flag? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not have the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ronniel1 always flag means that kuberenetes will try to pull the image from external repo every time, that's why we need to set never on subsystem There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but in this case there will not be an external repo |
||
pullPolicy = "Never" | ||
} | ||
ret := &batch.Job{ | ||
TypeMeta: meta.TypeMeta{ | ||
Kind: "Job", | ||
|
@@ -323,7 +328,7 @@ func (k *kubeJob) createKubeconfigJob(cluster *common.Cluster, jobName string, c | |
{ | ||
Name: ignitionGeneratorPrefix, | ||
Image: ignitionGeneratorImage, | ||
ImagePullPolicy: "Always", | ||
ImagePullPolicy: pullPolicy, | ||
Env: []core.EnvVar{ | ||
{ | ||
Name: "S3_ENDPOINT_URL", | ||
|
@@ -345,6 +350,10 @@ func (k *kubeJob) createKubeconfigJob(cluster *common.Cluster, jobName string, c | |
Name: "S3_BUCKET", | ||
Value: k.Config.S3Bucket, | ||
}, | ||
{ | ||
Name: "S3_REGION", | ||
Value: k.Config.S3Region, | ||
}, | ||
{ | ||
Name: "CLUSTER_ID", | ||
Value: id.String(), | ||
|
@@ -354,11 +363,11 @@ func (k *kubeJob) createKubeconfigJob(cluster *common.Cluster, jobName string, c | |
Value: k.ReleaseImage, //TODO: change this to match the cluster openshift version | ||
}, | ||
{ | ||
Name: "aws_access_key_id", | ||
Name: "AWS_ACCESS_KEY_ID", | ||
Value: k.Config.AwsAccessKeyID, | ||
}, | ||
{ | ||
Name: "aws_secret_access_key", | ||
Name: "AWS_SECRET_ACCESS_KEY", | ||
Value: k.Config.AwsSecretAccessKey, | ||
}, | ||
}, | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export DUMMY_IGNITION=minikube-local-registry/ignition-dummy-generator:minikube-test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ronniel1 kubernetes will still treat it as external and will try to connect