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

Initial draft GitBook. #566

Merged
merged 17 commits into from
Nov 5, 2018
Merged

Initial draft GitBook. #566

merged 17 commits into from
Nov 5, 2018

Conversation

davidewatson
Copy link
Contributor

@davidewatson davidewatson commented Oct 29, 2018

What this PR does / why we need it:

The Cluster API has seen a fair number of changes over the course of the past year. At the same time, there has been a significant increase in the number of providers. Clear developer documentation is needed in order to make implementation easier and maintain consistent behavior.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):

Begins to fix #505

Special notes for your reviewer:

I am going to push the generated code in a second commit for ease of review. It may also make sense for me to break this up further to both obtain consensus for this PR, and facilitate further writing.

To view this GitBook locally while we sort out which account will be used to serve the final product, you may install GitBook and then:

cd $GOPATH/src/sigs.k8s.io/cluster-api
git fetch origin pull/566/head:gitbook
git checkout gitbook
cd docs/book
gitbook install
gitbook build
gitbook serve

You may then view the book locally open http://localhost:4000...

Release note:

Initial developer documentation.

@k8s-ci-robot k8s-ci-robot requested review from karan and krousey October 29, 2018 02:59
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 29, 2018
docs/book/SUMMARY.md Outdated Show resolved Hide resolved
docs/book/common_code/architecture.md Outdated Show resolved Hide resolved
docs/book/common_code/architecture.md Outdated Show resolved Hide resolved
docs/book/common_code/cluster_controller.md Outdated Show resolved Hide resolved
docs/book/common_code/cluster_controller.md Outdated Show resolved Hide resolved

{% sample lang="go" %}
```go
// MachineTemplateSpec describes the data a machine should have when created from a template
Copy link

Choose a reason for hiding this comment

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

s/a machine should have when created from a template/needed to create a Machine from a template/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed with my latest commit.

docs/book/common_code/reponsitory_layout.md Outdated Show resolved Hide resolved
docs/book/provider_implementations/generate_crds.md Outdated Show resolved Hide resolved
docs/book/provider_implementations/generate_crds.md Outdated Show resolved Hide resolved
@davidewatson
Copy link
Contributor Author

davidewatson commented Oct 29, 2018

Remaining tasks which may or may not be dealt with within this PR: #571

@phyber, @randomvariable, @hardikdr, @oneilcin, @detiber, @chuckha, @kris-nova

Copy link
Member

@detiber detiber left a comment

Choose a reason for hiding this comment

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

A few comments and questions, but overall this is outstanding work!

docs/book/common_code/machine_controller.md Show resolved Hide resolved
docs/book/common_code/machine_controller.md Outdated Show resolved Hide resolved
{% sample lang="go" %}
```go
// MachineStatus defines the observed state of Machine
type MachineStatus struct {
Copy link
Member

Choose a reason for hiding this comment

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

Is there some tooling to sync these structs with the current versions? If not, we may want to track that as a followup item to avoid drift.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed that duplicating this code is a Bad Idea (tm). I've found two GitBook plugins which support including code snippets: include-codeblock and snippet. Both of them assume Doxygen markers, which seems reasonable to me. If we are okay with adding those to the source I'll take a look.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hopefully those play well with the code generation.... :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

include-codebook is more popular (29 vs 2 stars, 22 vs 2 forks) and has seen more recent development (though not by much).

As an example, with this code change:

diff --git a/pkg/apis/cluster/v1alpha1/machinedeployment_types.go b/pkg/apis/cluster/v1alpha1/machinedeployment_types.go
index d3017c05d..e27c880da 100644
--- a/pkg/apis/cluster/v1alpha1/machinedeployment_types.go
+++ b/pkg/apis/cluster/v1alpha1/machinedeployment_types.go
@@ -23,6 +23,7 @@ import (
        "sigs.k8s.io/cluster-api/pkg/apis/cluster/common"
 )
 
+/// [marker0]
 // MachineDeploymentSpec defines the desired state of MachineDeployment
 type MachineDeploymentSpec struct {
        // Number of desired machines. Defaults to 1.
@@ -67,6 +68,9 @@ type MachineDeploymentSpec struct {
        ProgressDeadlineSeconds *int32 `json:"progressDeadlineSteeconds,omitempty"`
 }
 
+/// [marker0]

The coresponding markdown looks like this:

{% method %}
## MachineDeploymentSpec

{% sample lang="go" %}
[import:'marker0'](../../../pkg/apis/cluster/v1alpha1/machinedeployment_types.go)
{% endmethod %}

So the resulting markdown is both less readable and more accurate...

`Cluster` in the same namespace as the `Machine`

There are two consequences of this:
- There must be at exactly one `Cluster` per namespace.
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest rewording this to say "There must no be more than one Cluster per namespace". The current wording seems to suggest that namespaces without a cluster would also be problematic.

Copy link
Contributor Author

@davidewatson davidewatson Oct 29, 2018

Choose a reason for hiding this comment

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

You are right. This is poorly worded.

For the machine actuator, I think we do require exactly one Cluster in the same namespace as the Machine:

func (c *ReconcileMachine) getCluster(machine *clusterv1.Machine) (*clusterv1.Cluster, error) {

#177 and #490 both discuss removing this restriction.

Maybe I should add informational panels to document these open issues.

# Generate manifests e.g. CRD, RBAC etc.
manifests:
- go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all
+ go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go crd
Copy link
Member

Choose a reason for hiding this comment

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

This probably isn't ideal. Ideally we'd be able to leverage more of the auto generation from kubebuilder. For the AWS implementation we disabled most of it for expedience as we were working on break-fix after the initial CRD migration.

Copy link
Contributor

Choose a reason for hiding this comment

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

Documenting the current state is a good idea though, because it points out these rough edges. I agree that we should fix. Let's file an issue (and it might even be a decent getting started issue).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@roberthbailey
Copy link
Contributor

/cc @pwittrock

docs/book/common_code/architecture.md Outdated Show resolved Hide resolved
docs/book/common_code/architecture.md Outdated Show resolved Hide resolved
at any time with the Namespace and Name of an object (Resource instance),
and it will make the cluster state match the state declared in the object
Spec. Upon completion, Reconcile updates the object Status to the new actual
state.
Copy link
Contributor

Choose a reason for hiding this comment

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

If the Reconcile function fails to update the actual state, ...

docs/book/common_code/cluster_controller.md Show resolved Hide resolved
docs/book/common_code/machine_controller.md Outdated Show resolved Hide resolved

{% panel style="warning", title="Important" %}
Does it make sense to identify a simple provider which may be easier to get
started with? Is that possible in a vendor neutral way?
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably not possible in a vendor neutral way. I think the best bet is to point to the list above and tell people to use the one for the environment that they want to be running in.

# Generate manifests e.g. CRD, RBAC etc.
manifests:
- go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all
+ go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go crd
Copy link
Contributor

Choose a reason for hiding this comment

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

Documenting the current state is a good idea though, because it points out these rough edges. I agree that we should fix. Let's file an issue (and it might even be a decent getting started issue).


```bash
minikube start
make deploy
Copy link
Contributor

Choose a reason for hiding this comment

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

Neat, I haven't actually tried this. Good to see that someone has.

# Repository Naming

The naming convention for new Cluster API [_provider_ repositories][repo-naming]
is generally of the form `cluster-api-provider-${cloud}`, where `${cloud}` is a,
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of "cloud" I've been using the term "environment". A cloud is one type of environment, as vsphere or openstack or bare metal (of which there are probably lots of variants).

@roberthbailey
Copy link
Contributor

Thanks for getting started on the docs. This looks great!

docs/book/common_code/architecture.md Outdated Show resolved Hide resolved
@phyber
Copy link

phyber commented Oct 30, 2018

This is looking great. 👍

@scruplelesswizard
Copy link

Awesome stuff @davidewatson! Thank you for picking this up

Copy link
Contributor

@chuckha chuckha left a comment

Choose a reason for hiding this comment

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

This is awesome. Bunch of minor comments.

docs/book/common_code/cluster_controller.md Outdated Show resolved Hide resolved
docs/book/common_code/cluster_controller.md Outdated Show resolved Hide resolved

Cluster has 4 fields:

`Spec` contains the desired cluster state specified by the object. While much
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be a little clearer if the order here matched the order they appeared in the struct below. I think a personal preference is to put the struct first then the explanation after, but I think this ordering works as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, will fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking more about this, I am not sure I agree. By placing the Spec and Status descriptions first aren't we are emphasizing the portion of the API which matters most to the implementor?

Copy link
Contributor

Choose a reason for hiding this comment

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

i can see it both ways, totally fine to keep it as is

docs/book/common_code/machine_controller.md Show resolved Hide resolved
```go
// MachineSpec defines the desired state of Machine
type MachineSpec struct {
// This ObjectMeta will autopopulate the Node created. Use this to
Copy link
Contributor

Choose a reason for hiding this comment

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

I opened a cluster-api issue since these have golint issues: #570

docs/book/provider_implementations/create_actuators.md Outdated Show resolved Hide resolved
docs/book/provider_implementations/register_schemes.md Outdated Show resolved Hide resolved
@randomvariable
Copy link
Member

This looks pretty great.

For remaining tasks, we can track these in an "UMBRELLA: Gitbook" issue.

Just as a test, was able to get this to push to Github pages. Would require renaming the current docs directory to work.

@davidewatson
Copy link
Contributor Author

davidewatson commented Oct 31, 2018

@randomvariable: I like the features of firebase, and see some value in maintaining consistency with kubebuilder, but gh-pages are free and therefore more likely to be replicated by other kubebuilder projects. Maybe we can discuss briefly tomorrow and make a decision. I'll also create an umbrella issue for the major items which are missing. A rihanna isssue: #571 Thanks!

@davidewatson
Copy link
Contributor Author

I have updated the deployment instructions. Once this is merged someone with admin privileges will need to:

  • Create the gh-pages branch:
git subtree push --prefix docs/book/_book origin gh-pages
  • Enable gh-pages from the Setting pane:

github pages configuration

/assign @roberthbailey

@roberthbailey
Copy link
Contributor

I'm happy to approve once someone lgtm's this who has reviewed it somewhat carefully (I took a quick pass on the docs but from the call today it sounded like other folks had done a much better job reviewing them than I have).

@detiber
Copy link
Member

detiber commented Nov 1, 2018

/test pull-cluster-api-test

<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<meta name="author" content="SIG Lifecycle Team">

Copy link

Choose a reason for hiding this comment

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

Can we get rid of the excessive number of empty lines in these html files ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anything under docs/book/_book/ is rendered so we would have to fix GitBook if we wanted to make their removal permanent...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is strange. Maybe there is a stray new line (or two!) somewhere. I'll look into it.

Copy link

Choose a reason for hiding this comment

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

Are you aware of this discussion on gitbook's future as an open source project:
GitbookIO/gitbook#1808
GitbookIO/gitbook#2148

it seems the new version does not support self-hosting anymore
https://docs.gitbook.com/v2-changes/important-differences

Copy link
Contributor Author

@davidewatson davidewatson Nov 2, 2018

Choose a reason for hiding this comment

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

It may be we that we have to or should migrate to netlify in the future. @timothysc suggested this last week since it is what k8s uses.

If we do it might also be nice to migrate kubebuilder as well. I am unsure if there is interest on that front but I think there is value in leveraging kubebuilder to the extent possible since this will make it easier for others to create high quality CRDs. @pwittrock

For now I'd like to get this merged so that we can parallize and iterate. @detiber, @roberthbailey, thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

I see no reason to block this now, but it'll definitely be worth tracking it for later followup.

Copy link

Choose a reason for hiding this comment

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

+1 for merging, I didn't intend to block this, content is more important than the tool

k8s documentation is written in markdown, processed using Hugo and served using netlify
https://kubernetes.io/docs/contribute/start/#the-basics-about-our-docs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the link!

@roberthbailey
Copy link
Contributor

/assign @detiber

@detiber
Copy link
Member

detiber commented Nov 5, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 5, 2018
@roberthbailey
Copy link
Contributor

Let's get this in and we can iterate from there.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: davidewatson, roberthbailey

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 5, 2018
@roberthbailey
Copy link
Contributor

/test pull-cluster-api-test

@k8s-ci-robot k8s-ci-robot merged commit df337dc into kubernetes-sigs:master Nov 5, 2018
@roberthbailey
Copy link
Contributor

I tried to follow the instructions above to push to a branch to serve on gh pages but it didn't work:

$ git subtree push --prefix docs/book/_book upstream gh-pages
git: 'subtree' is not a git command. See 'git --help'.

Thoughts?

@msohn
Copy link

msohn commented Nov 6, 2018

Usually git subtree comes in the ./share/git-core/contrib/ folder of a git installation.
On Mac it just works for me using git 2.19.1:

$ git subtree
usage: git subtree add   --prefix=<prefix> <commit>
   or: git subtree add   --prefix=<prefix> <repository> <ref>
   or: git subtree merge --prefix=<prefix> <commit>
   or: git subtree pull  --prefix=<prefix> <repository> <ref>
   or: git subtree push  --prefix=<prefix> <repository> <ref>
   or: git subtree split --prefix=<prefix> <commit...>

    -h, --help            show the help
    -q                    quiet
    -d                    show debug messages
    -P, --prefix ...      the name of the subdir to split out
    -m, --message ...     use the given message as the commit message for the merge commit

options for 'split'
    --annotate ...        add a prefix to commit message of new commits
    -b, --branch ...      create a new branch from the split subtree
    --ignore-joins        ignore prior --rejoin commits
    --onto ...            try connecting new tree to an existing one
    --rejoin              merge the new branch back into HEAD

options for 'add', 'merge', and 'pull'
    --squash              merge subtree changes as a single commit

@davidewatson
Copy link
Contributor Author

My guess is either thegit-subtree command is not installed or it is not in your $PATH (see https://git-scm.com/docs/git#git---list-cmdsgroupgroup82308203). On MacOS, when git-subtree is installed using brew, I find it here:

rodin:~ dwat$ which git-subtree
/usr/local/bin/git-subtree
rodin:~ dwat$ 

The instructions I found for installing git-subtree on StackOverflow say to download git and compile from source if it is not available as a package for your distro. You can also install only git-subtree using these instructions.

@roberthbailey
Copy link
Contributor

@davidewatson - I gave you write access to the repo; can you run the git subtree commands and get the branch pushed? I have a google-installed version of git and don't feel like breaking it right now to get the subtree command working via brew. :)

@davidewatson davidewatson deleted the gitbook branch December 21, 2018 16:57
jayunit100 pushed a commit to jayunit100/cluster-api that referenced this pull request Jan 31, 2020
…const

use govmomi types.VirtualEthernetCardMacType for NIC address type
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", 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.

Clear documentation for machine and cluster actuator interface
9 participants