Skip to content

[wmco] Barebone WMCO initialization - #1

Merged
aravindhp merged 1 commit into
openshift:masterfrom
ravisantoshgudimetla:barebone-wmco-init
Feb 21, 2020
Merged

aravindhp merged 1 commit into
openshift:masterfrom
ravisantoshgudimetla:barebone-wmco-init

Conversation

@ravisantoshgudimetla

@ravisantoshgudimetla ravisantoshgudimetla commented Feb 18, 2020

Copy link
Copy Markdown
Contributor

Followed the steps at https://github.com/operator-framework/operator-sdk/blob/master/doc/user-guide.md to initialize the repo, as of now, following items are added:

  • A new apiVersion called wmc.openshift.io/v1alpha1
  • A new kind called WindowsMachineConfig
  • A deployable CRD, CR, rbac and sa
  • Controller which watches for WindowsMachineConfig CRs

The goal is to have the operator watch for windowsMachineConfig CR and windowsMachineConfig Configmap in future. As of now, we're just going to watch for the windowsConfig CR(which is singleton)

Following are the commands, that I ran:

    # operator-sdk new windows-machine-config-operator --repo=github.com/example-inc/memcached-operator
    # operator-sdk add api --api-version=wmc.openshift.io/v1alpha1 --kind=WindowsMachineConfig
    # operator-sdk generate k8s
    # operator-sdk generate crds
    # operator-sdk add controller --api-version=wmc.openshift.io/v1alpha1 --kind=WindowsMachineConfig

@openshift-ci-robot openshift-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Feb 18, 2020
@ravisantoshgudimetla

Copy link
Copy Markdown
Contributor Author

/cc @aravindhp @openshift/openshift-team-windows-containers

@openshift-ci-robot
openshift-ci-robot requested review from a team and aravindhp February 18, 2020 21:11

@aravindhp aravindhp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for working on this, @ravisantoshgudimetla.

Please add the operator-sdk commands that you ran to initialize the repo. Also shouldn't you add WindowsMachine CR first given you are going to be working on that next?

metadata:
name: windowsoperatorconfigs.winoperators.config.openshift.io
spec:
group: winoperators.config.openshift.io

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are we sure we can use config.openshift.io for operators that perform day 2 operations? @sdodson @crawford please weigh in here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@deads2k please weigh in here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This has been resolved over slack. As per @deads2k, config.openshift.io must lifecycle on an OpenShift release cadence. and that the configuration should live with the component.

@ravisantoshgudimetla

Copy link
Copy Markdown
Contributor Author

Also shouldn't you add WindowsMachine CR first given you are going to be working on that next?

I'll pick it up later when I pick that story. I want to not block you. Also, I wasn't sure, if we have to remove certain fields in the CR, so I did not want to block this PR on that.

@aravindhp

Copy link
Copy Markdown
Contributor

I'll pick it up later when I pick that story. I want to not block you. Also, I wasn't sure, if we have to remove certain fields in the CR, so I did not want to block this PR on that.

Given we are waiting on @deads2k it makes sense to add your CRD first and I can add the WindowsMachineConfig CRD as part of my story. Adding the CRD is not a blocker for me. That way I can start working on it as soon as this merges.

@ravisantoshgudimetla

Copy link
Copy Markdown
Contributor Author

Please add the operator-sdk commands that you ran to initialize the repo.

I added link to the commands I've run. Do you want me to add the exact commands as well?

@aravindhp

Copy link
Copy Markdown
Contributor

I added link to the commands I've run. Do you want me to add the exact commands as well?

Yes please.

@ravisantoshgudimetla
ravisantoshgudimetla force-pushed the barebone-wmco-init branch 2 times, most recently from 8144acb to e4ff810 Compare February 20, 2020 22:18

@aravindhp aravindhp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR, @ravisantoshgudimetla. Mostly LGTM.

Comment on lines +12 to +13
// Replicas represent how many Windows nodes to be added to the
// OpenShift cluster

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please fix

Comment on lines +22 to +27
// sshPrivateKey is the name of the secret which contains ssh key
// to decrypt the password
sshPrivateKey string `json:"sshprivatekey"`
// cloudProviderCreds is the name of the secret which contains
// credentials of the cloud provider.
cloudProviderCredentials string `json:"cloudprovidercredentials,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please indicate in the variable name that we are using a secret.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be better to create a struct for AWS as this is just going to grow. We can add a struct for Azure when we start working on adding Azure support.

@sebsoto sebsoto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems cool, thanks @ravisantoshgudimetla

// InstanceType represents the flavor of instance to be used while
// creating the virtual machines. Please note that this is common
// across all the Windows nodes in the cluster
InstanceType string `json:"instancetype,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For the json tags we should use a set naming convention. Kubernetes uses camel case so I suggest we go with that :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I just looked OpenShift api and we moved to that. Thnx.

InstanceType string `json:"instancetype,omitempty"`
// sshkeyPair is the sshKeyPair associated with cloudprovider. AWS
// asks a keypair to be present for encrypting the Windows VM password
sshkeyPair string `json:"sshkeypair"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sshkeyPair -> sshKeyPair

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// WindowsMachineConfigSpec defines the desired state of WindowsMachineConfig
type WindowsMachineConfigSpec struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should Windows build number be added as a field here?
According to the link:

The Windows Server version used by each pod must match that of the node

It seems that there are multiple builds (versions) for Windows Server 2019. Based on that it would seem that we should keep note of the build number so that we would know if a pod could be scheduled on the node or not due to version reasons.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As of now, the focus is on getting the Windows Server 2019 to the cluster(that's why I am not exposing the image to be used as of now). We may not go to the granular level of matching builds in future but we can always increase the surface area of api if we want to.

@suhanime suhanime left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you for the PR @ravisantoshgudimetla. The ground work looks solid.

Comment thread cmd/manager/main.go
// Get a config to talk to the apiserver
cfg, err := config.GetConfig()
if err != nil {
log.Error(err, "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why are the errors swallowed here and in the following sections?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We're not swallowing them, we're not adding context however remember that this PR is just what sdk generates. I'll make code changes in the next PR.

@ravisantoshgudimetla
ravisantoshgudimetla force-pushed the barebone-wmco-init branch 2 times, most recently from 217b901 to 50a0923 Compare February 21, 2020 17:33
// across all the Windows nodes in the cluster
InstanceType string `json:"instanceType,omitempty"`
// AWSProvider holds AWS specific cloud provider information.
AWSProvider *AWSProvider `json:"AWSProvider"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

From what I understand, this should be awsProvider in the JSON. You can check with the API folks to confirm.

Please remove the provider suffix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Anything works, in json that we need to edit, the user needs to provide AWSProvider.

// AWSProvider holds AWS specific cloud provider information.
AWSProvider *AWSProvider `json:"AWSProvider"`
// AzureProvider holds Azure specific cloud provider information
AzureProvider *AzureProvider `json:"AzureProvider"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rename to Azure and make it azure in the JSON

type AWSProvider struct {
// SshKeyPair is the sshKeyPair associated with cloudprovider. AWS
// asks a keypair to be present for encrypting the Windows VM password
SshKeyPair string `json:"sshKeyPair"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this be SSHKeyPair?

SshKeyPair string `json:"sshKeyPair"`
// SshPrivateKey is the name of the secret which contains ssh key
// to decrypt the password
SshPrivateKey string `json:"sshPrivateKey"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same question here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No strong preference. I'll change it to SSH.

// to decrypt the password
SshPrivateKey string `json:"sshPrivateKey"`
// CredentialAccountID is account id associated with AWS provider
CredentialAccountID string `json:credentialAccountDd"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please change to credentialAccountId in the JSON.

@aravindhp aravindhp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/approve

@ravisantoshgudimetla ravisantoshgudimetla left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@aravindhp - I addressed your comments. PTAL

// across all the Windows nodes in the cluster
InstanceType string `json:"instanceType,omitempty"`
// AWSProvider holds AWS specific cloud provider information.
AWSProvider *AWSProvider `json:"AWSProvider"`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Anything works, in json that we need to edit, the user needs to provide AWSProvider.

SshKeyPair string `json:"sshKeyPair"`
// SshPrivateKey is the name of the secret which contains ssh key
// to decrypt the password
SshPrivateKey string `json:"sshPrivateKey"`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No strong preference. I'll change it to SSH.

@suhanime

Copy link
Copy Markdown

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 21, 2020
Followed the steps at
https://github.com/operator-framework/operator-sdk/blob/master/doc/user-guide.md
to initialize the repo, as of now, following items are added:

    - A new apiVersion called wmc.openshift.io/v1alpha1
    - A new kind called WindowsMachineConfig
    - A deployable CRD, CR, rbac and sa
    - Controller which watches for WindowsMachineConfig CRs

The goal is to have the operator watch for windowsMachineConfig CR and
windowsMachineConfig Configmap in future. As of now, we're just going to watch
for the windowsConfig CR(which is singleton)

Following are the commands, that I ran:

    - operator-sdk new windows-machine-config-operator \
	--repo=github.com/example-inc/memcached-operator
    - operator-sdk add api --api-version=wmc.openshift.io/v1alpha1 \
      --kind=WindowsMachineConfig
    - operator-sdk generate k8s
    - operator-sdk generate crds
    - operator-sdk add controller --api-version=wmc.openshift.io/v1alpha1 \
      --kind=WindowsMachineConfig
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Feb 21, 2020
@aravindhp

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 21, 2020
@aravindhp
aravindhp merged commit d75d5ce into openshift:master Feb 21, 2020
wgahnagl pushed a commit to wgahnagl/windows-machine-config-operator that referenced this pull request Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants