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

operators scaffolding #198

Closed
wants to merge 2 commits into from
Closed

Conversation

rajatchopra
Copy link

Just the scaffolding and some skeleton for the kubecore operator.
Follow up commits will fill up kubecore and figure out what to do with clusterversion operator etc.

@wking @staebler @yifan-gu @abhinavdahiya Feedback please. I still have less grasp about the order of operators (or even the list of them all).

Signed-off-by: Rajat Chopra rchopra@redhat.com

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rajatchopra

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 31, 2018
@wking
Copy link
Member

wking commented Aug 31, 2018

/lint

Copy link
Contributor

@openshift-ci-robot openshift-ci-robot left a comment

Choose a reason for hiding this comment

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

@wking: 11 warnings.

In response to this:

/lint

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@@ -0,0 +1,35 @@
package operators
Copy link
Contributor

Choose a reason for hiding this comment

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

Golint comments: should have a package comment, unless it's in another file for this package. More info.

NetworkOperator() asset.Asset
}

type StockImpl struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Golint comments: exported type StockImpl should have comment or be unexported. More info.


var _ Stock = (*StockImpl)(nil)

func (s *StockImpl) EstablishStock(rootDir string, stock installconfig.Stock) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Golint comments: exported method StockImpl.EstablishStock should have comment or be unexported. More info.

//s.clusterVersionOperator = &clusterVersionOperator{}
}

func (s *StockImpl) Operators() asset.Asset { return s.operators }
Copy link
Contributor

Choose a reason for hiding this comment

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

Golint comments: exported method StockImpl.Operators should have comment or be unexported. More info.

}

func (s *StockImpl) Operators() asset.Asset { return s.operators }
func (s *StockImpl) ClusterVersionOperator() asset.Asset { return s.clusterVersionOperator }
Copy link
Contributor

Choose a reason for hiding this comment

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

Golint comments: exported method StockImpl.ClusterVersionOperator should have comment or be unexported. More info.

func (s *StockImpl) Operators() asset.Asset { return s.operators }
func (s *StockImpl) ClusterVersionOperator() asset.Asset { return s.clusterVersionOperator }
func (s *StockImpl) KubeCoreOperator() asset.Asset { return s.kubeCoreOperator }
func (s *StockImpl) NetworkOperator() asset.Asset { return s.networkOperator }
Copy link
Contributor

Choose a reason for hiding this comment

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

Golint comments: exported method StockImpl.NetworkOperator should have comment or be unexported. More info.

@@ -0,0 +1,40 @@
package operators
Copy link
Contributor

Choose a reason for hiding this comment

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

Golint comments: should have a package comment, unless it's in another file for this package. More info.

"github.com/openshift/installer/pkg/asset/installconfig"
)

type Stock interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Golint comments: exported type Stock should have comment or be unexported. More info.

@@ -0,0 +1,132 @@
package operators
Copy link
Contributor

Choose a reason for hiding this comment

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

Golint comments: should have a package comment, unless it's in another file for this package. More info.


data, err := yaml.Marshal(coreConfig)
if err != nil {
return nil, fmt.Errorf("Failed to marshal core config: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Golint errors: error strings should not be capitalized or end with punctuation or a newline. More info.

Copy link
Member

@wking wking left a comment

Choose a reason for hiding this comment

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

Sorry for the nit-level review :p, but I thought I'd comment on these while I was wrapping my head around where you were going.

I'm personally not clear on how much of this is going to get stubbed into the asset graph (as you have here) to be set up pre-Terraform (although there are hints of this approach in some stale docs). I'm working on internalizing the existing discussion on this, and then I'll give this PR another look.

if !ok {
return nil, fmt.Errorf("failed to get install config state in the dependent asset states")
}
if err := yaml.Unmarshal(state.Contents[0].Data, &kco.installConfig); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

nit: you can use GetInstallConfig (new in #160) for this.

}

// installconfig is ready, we can create the core config from it now
coreConfig, err := kco.coreConfig()
Copy link
Member

Choose a reason for hiding this comment

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

nit: I'd rather pass the *InstallConfig through as an argument here, instead of holding a copy in the kubeCoreOperator struct itself.

@rajatchopra rajatchopra force-pushed the operators branch 2 times, most recently from 4e1d28d to 85e32be Compare September 11, 2018 23:28
@openshift-ci-robot openshift-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 11, 2018
@@ -0,0 +1,110 @@
package operators
Copy link
Contributor

Choose a reason for hiding this comment

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

can you rename the file to kube_addon_operator.go seems like other files follow that convention.

kao.installConfig = ic

// installconfig is ready, we can create the addon config from it now
addonConfig, err := kao.addonConfig()
Copy link
Contributor

Choose a reason for hiding this comment

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

can you pass installconfig to the func rather than implicit through kao? eg: https://github.com/openshift/installer/blob/master/pkg/asset/ignition/bootstrap.go#L131

Kind: kubeaddon.Kind,
},
}
addonConfig.CloudProvider = tectonicCloudProvider(kao.installConfig.Platform)
Copy link
Contributor

Choose a reason for hiding this comment

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

tectonicCloudProvider like functions should be part of installconfig package.

},
}
addonConfig.CloudProvider = tectonicCloudProvider(kao.installConfig.Platform)
addonConfig.ClusterConfig.APIServerURL = kao.getAPIServerURL()
Copy link
Contributor

Choose a reason for hiding this comment

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

getAPIServerURL: tls package might have required something similar too, maybe some common package?(installconfig)

func (kco *kubeCoreOperator) getBaseAddress() string {
return fmt.Sprintf("%s.%s", kco.installConfig.ClusterName, kco.installConfig.BaseDomain)
}

Copy link
Contributor

@abhinavdahiya abhinavdahiya Sep 15, 2018

Choose a reason for hiding this comment

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

all these functions seem like will be used by multiple assets. there should be a common source of finding these.

addon := dependencies[o.assetStock.KubeAddonOperator()].Contents[0]

// kco+no+tnco go to kube-system config map
kubeSys, err := configMap("kube-system", "cluster-config-v1", genericData{
Copy link
Contributor

Choose a reason for hiding this comment

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

This asset generate seems to be just cluster config, Can we have these configs be separate assets?

return str, nil
}

func marshalYAML(obj interface{}) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems to be a function that us already present in some common package?

Copy link
Author

Choose a reason for hiding this comment

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

Ack.
Maybe all of this file's contents can be moved out. This is the common utils package being born.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 15, 2018
@rajatchopra rajatchopra force-pushed the operators branch 3 times, most recently from 4b51486 to 1312e0a Compare September 17, 2018 21:46
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 17, 2018
@@ -0,0 +1,90 @@
package operators
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't install TNCO anymore. Please use MCO instead.

kubeCoreOperator asset.Asset
networkOperator asset.Asset
tnco asset.Asset
addon asset.Asset
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use consistent names.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed.


// StockImpl implements the Stock interface for operators
type StockImpl struct {
operators asset.Asset
Copy link
Contributor

Choose a reason for hiding this comment

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

This name isn't very accurate. It's two different configs that really should be separate assets.

Copy link
Author

Choose a reason for hiding this comment

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

I didn't get this. Explain? Its the parent (gathering asset) and the dependent assets.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, that comment was supposed to be on the StockImpl in pkg/asset/operators/stock.go.

directory: rootDir,
}
// TODO:
//s.clusterVersionOperator = &clusterVersionOperator{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Without this populated, the asset store panics.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed that. The main.go has an operators command. It runs and dumps the config.yaml.

Rajat Chopra added 2 commits September 17, 2018 20:35
operator config and manifests for:
1. tnco (to be replaced by mco)
2. network-operator
3. kube-core-operator
4. kube-addon-operator
@@ -13,6 +13,7 @@ import (
var (
installConfigCommand = kingpin.Command("install-config", "Generate the Install Config asset")
ignitionConfigsCommand = kingpin.Command("ignition-configs", "Generate the Ignition Config assets")
operatorsCommand = kingpin.Command("operators", "Generate the Operator assets")
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be called "manifests".

@@ -33,6 +34,10 @@ func main() {
assetStock.MasterIgnition(),
assetStock.WorkerIgnition(),
}
case operatorsCommand.FullCommand():
targetAssets = []asset.Asset{
assetStock.Operators(),
Copy link
Contributor

Choose a reason for hiding this comment

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

What about all of the other manifests? This only renders openshift-config.yaml and cluster-config.yaml (which is very confusing given the name of this asset.

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// kubeAddonOperator generates the network-operator-*.yml files
Copy link
Contributor

Choose a reason for hiding this comment

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

Use yaml instead of yml.

Data: addonConfig,
},
{
Name: filepath.Join(kao.directory, "kube-addon-operator-manifests.yml"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Singular manifest.

}

func (kao *kubeAddonOperator) getAPIServerURL() string {
return fmt.Sprintf("https://%s-api.%s:6443", kao.installConfig.ClusterName, kao.installConfig.BaseDomain)
Copy link
Contributor

Choose a reason for hiding this comment

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

This ends up as https://-api.base.domain:6443 on my system.

}
addonConfig.CloudProvider = tectonicCloudProvider(kao.installConfig.Platform)
addonConfig.ClusterConfig.APIServerURL = kao.getAPIServerURL()
registrySecret, err := generateRandomID(16)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just use

instead.

@wking
Copy link
Member

wking commented Sep 19, 2018

Replaced by #286.

@wking wking closed this Sep 19, 2018
@rajatchopra rajatchopra deleted the operators branch October 11, 2018 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants