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

Adds cluster config generation with kubeadm #113

Merged
merged 3 commits into from
Jan 24, 2022

Conversation

prateekgogia
Copy link
Member

@prateekgogia prateekgogia commented Jan 14, 2022

Issue #, if available:
Description of changes:

  • Creates an S3 bucket
  • Generate kubeadm config for master and etcd components
  • Uploads these config to S3 bucket
  • Configure user-data to pull from S3 bucket
  • Configure kubelet config for systemd

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@@ -46,6 +46,9 @@ func (s *Subnets) Create(ctx context.Context, substrate *v1alpha1.Substrate) (re
return reconcile.Result{}, err
}
for _, subnet := range subnets {
if subnet == nil { // we can run into a case when ctx is canceled, errs and subnets are all nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ctx is cancelled, don't you have an error value caught on line 45?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I ran into this, err was nil and because we have subnets slice with nils defined on line 40, we enter this for loop.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's gotta be a bug somewhere else.

)

const (
clusterCertsBasePath = "/tmp/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, this will create a temp dir with random strings as suffix, we want to discover existing certs and configs atleast locally if someone runs the cli again to create same substrate cluster.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certs probably shouldn't change. Kubernete configs need to change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're also not guaranteed that the host os even has a /tmp dir, which the go library has mechanisms to handle.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets discuss about this, I am probably missing some context here

}

// UploadObject uploads a file
func (d *DirectoryIterator) UploadObject() s3manager.BatchUploadObject {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this upload in parallel?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SDK enables you to pass custom iterators to the new batched operations. For example, if we want to upload a directory, none of the default iterators do this easily. The following example shows how to implement a custom iterator that uploads a directory to S3.

Man -- instead of writing docs, why not write a directory iterator :O

}

// Err returns error of DirectoryIterator
func (d *DirectoryIterator) Err() error {
Copy link
Contributor

@ellistarn ellistarn Jan 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you're just copying the docs, but this impl is pretty weak. We can leave as is for now.

Copy link
Member Author

@prateekgogia prateekgogia Jan 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I wanted something quick and that worked. Later I found I also used this same logic in the earlier implementation Lol.
We can revisit and make it more robust.

Copy link
Contributor

@ellistarn ellistarn Jan 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you cut an issue? label: operational-excellence

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


func (c *Config) Delete(ctx context.Context, substrate *v1alpha1.Substrate) (reconcile.Result, error) {
// delete the s3 bucket
if err := s3manager.NewBatchDeleteWithClient(c.S3).Delete(ctx, s3manager.NewDeleteListIterator(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to delete the files. Just delete the bucket.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fails to delete the bucket if it still has files in it, I will check if there is a --force kind of option

Copy link
Contributor

@ellistarn ellistarn Jan 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No!? 😲

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked at this there is no force option in the request

@prateekgogia prateekgogia changed the title [WIP] Adds cluster config generation with kubeadm Adds cluster config generation with kubeadm Jan 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants