-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
[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 |
/lint |
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.
@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 |
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.
Golint comments: should have a package comment, unless it's in another file for this package. More info.
pkg/asset/operators/stock.go
Outdated
NetworkOperator() asset.Asset | ||
} | ||
|
||
type StockImpl struct { |
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.
Golint comments: exported type StockImpl should have comment or be unexported. More info.
pkg/asset/operators/stock.go
Outdated
|
||
var _ Stock = (*StockImpl)(nil) | ||
|
||
func (s *StockImpl) EstablishStock(rootDir string, stock installconfig.Stock) { |
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.
Golint comments: exported method StockImpl.EstablishStock should have comment or be unexported. More info.
pkg/asset/operators/stock.go
Outdated
//s.clusterVersionOperator = &clusterVersionOperator{} | ||
} | ||
|
||
func (s *StockImpl) Operators() asset.Asset { return s.operators } |
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.
Golint comments: exported method StockImpl.Operators should have comment or be unexported. More info.
pkg/asset/operators/stock.go
Outdated
} | ||
|
||
func (s *StockImpl) Operators() asset.Asset { return s.operators } | ||
func (s *StockImpl) ClusterVersionOperator() asset.Asset { return s.clusterVersionOperator } |
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.
Golint comments: exported method StockImpl.ClusterVersionOperator should have comment or be unexported. More info.
pkg/asset/operators/stock.go
Outdated
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 } |
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.
Golint comments: exported method StockImpl.NetworkOperator should have comment or be unexported. More info.
@@ -0,0 +1,40 @@ | |||
package operators |
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.
Golint comments: should have a package comment, unless it's in another file for this package. More info.
pkg/asset/operators/stock.go
Outdated
"github.com/openshift/installer/pkg/asset/installconfig" | ||
) | ||
|
||
type Stock interface { |
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.
Golint comments: exported type Stock should have comment or be unexported. More info.
@@ -0,0 +1,132 @@ | |||
package operators |
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.
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) |
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.
Golint errors: error strings should not be capitalized or end with punctuation or a newline. More info.
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.
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 { |
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.
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() |
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.
nit: I'd rather pass the *InstallConfig
through as an argument here, instead of holding a copy in the kubeCoreOperator
struct
itself.
4e1d28d
to
85e32be
Compare
@@ -0,0 +1,110 @@ | |||
package operators |
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.
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() |
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.
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) |
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.
tectonicCloudProvider
like functions should be part of installconfig
package.
}, | ||
} | ||
addonConfig.CloudProvider = tectonicCloudProvider(kao.installConfig.Platform) | ||
addonConfig.ClusterConfig.APIServerURL = kao.getAPIServerURL() |
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.
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) | ||
} | ||
|
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.
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{ |
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.
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) { |
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.
this seems to be a function that us already present in some common package?
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.
Ack.
Maybe all of this file's contents can be moved out. This is the common utils package being born.
4b51486
to
1312e0a
Compare
@@ -0,0 +1,90 @@ | |||
package operators |
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.
We don't install TNCO anymore. Please use MCO instead.
pkg/asset/operators/stock.go
Outdated
kubeCoreOperator asset.Asset | ||
networkOperator asset.Asset | ||
tnco asset.Asset | ||
addon asset.Asset |
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.
Please use consistent names.
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.
Fixed.
|
||
// StockImpl implements the Stock interface for operators | ||
type StockImpl struct { | ||
operators asset.Asset |
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.
This name isn't very accurate. It's two different configs that really should be separate assets.
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.
I didn't get this. Explain? Its the parent (gathering asset) and the dependent assets.
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.
Sorry, that comment was supposed to be on the StockImpl in pkg/asset/operators/stock.go.
directory: rootDir, | ||
} | ||
// TODO: | ||
//s.clusterVersionOperator = &clusterVersionOperator{} |
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.
Without this populated, the asset store panics.
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.
Fixed that. The main.go has an operators command. It runs and dumps the config.yaml.
operator config and manifests for: 1. tnco (to be replaced by mco) 2. network-operator 3. kube-core-operator 4. kube-addon-operator
1312e0a
to
101b1dc
Compare
@@ -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") |
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.
This should be called "manifests".
@@ -33,6 +34,10 @@ func main() { | |||
assetStock.MasterIgnition(), | |||
assetStock.WorkerIgnition(), | |||
} | |||
case operatorsCommand.FullCommand(): | |||
targetAssets = []asset.Asset{ | |||
assetStock.Operators(), |
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.
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 |
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.
Use yaml
instead of yml
.
Data: addonConfig, | ||
}, | ||
{ | ||
Name: filepath.Join(kao.directory, "kube-addon-operator-manifests.yml"), |
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.
Singular manifest.
} | ||
|
||
func (kao *kubeAddonOperator) getAPIServerURL() string { | ||
return fmt.Sprintf("https://%s-api.%s:6443", kao.installConfig.ClusterName, kao.installConfig.BaseDomain) |
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.
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) |
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.
Just use
func String(n int) string { |
Replaced by #286. |
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