Skip to content

Commit 9f0f8d4

Browse files
authored
Add support for shell documentation (cloudposse#467)
* Add support for shell documentation * Use front matter instead * formatting * fix formatting * add fzf support * Update formatting * fix typo * Update rootfs/usr/local/bin/docs Co-Authored-By: osterman <[email protected]>
1 parent a1ff70e commit 9f0f8d4

File tree

11 files changed

+238
-60
lines changed

11 files changed

+238
-60
lines changed

Dockerfile

+7
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,15 @@ ENV XDG_CONFIG_HOME=/etc
231231
# Clean up file modes for scripts
232232
RUN find ${XDG_CONFIG_HOME} -type f -name '*.sh' -exec chmod 755 {} \;
233233

234+
# Install "root" filesystem
234235
COPY rootfs/ /
235236

237+
# Install documentation
238+
COPY docs/ /usr/share/docs/
239+
240+
# Build man pages
241+
RUN /usr/local/bin/docs update
242+
236243
WORKDIR /conf
237244

238245
ENTRYPOINT ["/bin/bash"]

docs/README.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: README(1) | Geodesic
3+
author:
4+
- Erik Osterman
5+
date: May 2019
6+
---
7+
8+
## NAME
9+
10+
README - Documentation for Geodesic
11+
12+
## SYNOPSIS
13+
14+
This directory contains a number of markdown-formatted "man" pages. These will be available inside of the container.
15+
16+
## USAGE
17+
18+
### Build
19+
20+
To rebuild the man pages, run `docs update`
21+
22+
### List
23+
24+
To list all available man pages, run `help`. Then for more information on any topic, run `help` and pass the command as an argument.
25+
26+
### Search
27+
28+
To search for help, run `help "topic"` where `"topic"` is what you want more information on.
29+
30+
## CONTRIBUTING
31+
32+
All documentation for `geodesic` belongs in the `docs/` folder. Use markdown appropriate formatting and styles.
33+
34+
## LAYOUT
35+
36+
In order to be consistent with UNIX Man pages, all section titles should be *UPPERCASE* and begin with a single `##`.
37+
Subsections should be properly capitalized and use `###`. Avoid going more than (2) sections deep.
38+
39+
Use standard section names.
40+
41+
### Here are some examples.
42+
43+
- `## NAME` The name of the command or function, followed by a one-line description of what it does.
44+
- `## SYNOPSIS` In the case of a command, a formal description of how to run it and what command line options it takes. For program functions, a list of the parameters the function takes and which header file contains its declaration.
45+
- `## DESCRIPTION` A textual description of the functioning of the command or function.
46+
- `## EXAMPLES` Some examples of common usage.
47+
- `## SEE ALSO` A list of related commands or functions.
48+
- `## OPTIONS` A list of supported options for the command
49+
- `## SYNTAX` An explation of the command's syntax
50+
- `## ENVIRONMENT` A list of supported environment variables
51+
- `## RETURN VALUES` A breakdown of the expected return values or exit codes
52+
- `## STANDARDS` Some of the "best practices"
53+
- `## SECURITY CONSIDERATIONS` Recommended settings for safer operation
54+
- `## BUGS` Some known issues
55+
- `## HISTORY` Background on command to give readers more context
56+
57+
58+
# SEE ALSO
59+
- https://pandoc.org/MANUAL.html
60+
- https://en.wikipedia.org/wiki/Man_page
61+
- https://en.wikipedia.org/wiki/RTFM

docs/about.md

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
## Features
1+
---
2+
title: ABOUT(1) | Geodesic
3+
author:
4+
- Erik Osterman
5+
date: May 2019
6+
---
7+
8+
## NAME
9+
10+
about - About the Geodesic Cloud Automation Shell
11+
12+
## FEATURES
213

314
* **Secure** - TLS/PKI, OAuth2, MFA Everywhere, remote access VPN, [ultra secure bastion/jumphost](https://github.com/cloudposse/bastion) with audit capabilities and slack notifications, [IAM assumed roles](https://github.com/99designs/aws-vault/), automatic key rotation, encryption at rest, and VPCs
415
* **Repeatable** - 100% Infrastructure-as-Code with change automation and support for scriptable admin tasks in any language, including Terraform
516
* **Extensible** - A framework where everything can be extended to work the way you want to
617
* **Comprehensive** - our [helm charts library](https://github.com/cloudposse/charts) are designed to tightly integrate your cloud-platform with Github Teams and Slack Notifications and CI/CD systems like TravisCI, CircleCI or Jenkins
718
* **OpenSource** - Permissive [APACHE 2.0](LICENSE) license means no lock-in and no on-going license fees
819

9-
## Technologies
20+
## TECHNOLOGIES
1021

1122
At its core, Geodesic is a framework for provisioning cloud infrastructure and the applications that sit on top of it. We leverage as many existing tools as possible to facilitate cloud fabrication and administration. We're like the connective tissue that sits between all of the components of a modern cloud.
1223

@@ -27,6 +38,6 @@ At its core, Geodesic is a framework for provisioning cloud infrastructure and t
2738

2839
[](https://media.giphy.com/media/26FmS6BRnPVPo2FDq/source.gif)
2940

30-
## Documentation
41+
## SEE MORE
3142

3243
Extensive documentation is provided on our [Documentation Hub](https://docs.cloudposse.com/geodesic).

docs/design.md

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
# Design
1+
---
2+
title: DESIGN(1) | Geodesic
3+
author:
4+
- Erik Osterman
5+
date: May 2019
6+
---
27

3-
## An Opinionated Framework
8+
## NAME
9+
10+
design - Geodesic Design
11+
12+
### An Opinionated Framework
413

514
We designed this shell as the last layer of abstraction. It stitches all the tools together like `make`, `aws-cli`, `kops`, `helm`, `kubectl`, and `terraform`. As time progresses,
615
there will undoubtably be even more that come into play. For this reason, we chose to use a combination of `bash` and `make` which together are ideally suited to combine the
@@ -18,7 +27,7 @@ Since we use `make` under-the-hood, you can add all your ENVs at the end of the
1827
For the default environment variables, checkout `/etc/profile.d/defaults.sh`. We believe using ENVs this way is both consistent
1928
with the "cloud" (12-factor) way of doing things, as well as a clear way of communicating what values are being passed without using a complicated convention. Additionally, you can set & forget these ENVs in your shell.
2029

21-
## Layout Inside the Shell
30+
## LAYOUT
2231

2332
We leverage as many semantics of the linux shell as we can to make the experience as frictionless as possible.
2433

@@ -27,23 +36,24 @@ We leverage as many semantics of the linux shell as we can to make the experienc
2736
* `/etc/bash_completion.d` is where all bash completion scripts are kept and sourced when the shell starts.
2837
* `/usr/local/bin` has some helper scripts
2938
* `/etc/motd` is the current "Message of the Day"
30-
* `/mnt/local` is where we house the local state (like your temporary AWS credentials)
31-
* `/mnt/remote` is where we mount the S3 bucket for cluster state; these files are never written to disk and only kept in memory for security
39+
* `/localhost` is where we house the local state (like your temporary AWS credentials). This is mounted to your `HOME` directory.
3240
* `/conf` is where all configurations belong. For example, stick your terraform module invocations in this directory. When using `terraform`, the directory names are mapped directly to a bucket prefix for terraform state which include subdirectories (e.g. `/conf/us-west-2/vpc` will map to a state folder prefix of `us-west-2/vpc`).
3341

34-
## Extending the Shell
42+
## EXTENDING
3543

3644
Geodesic was written to be easily extended. There are a couple ways to do it.
3745

3846
You can easily extend the Geodesic shell by creating your own repo with a `Dockerfile`. We suggest you have it inherit `FROM geodeisc:latest` (or pin it to a [build number](https://travis-ci.org/cloudposse/geodesic) for stability). If you want to add or modify core functionality, this is the recommended way to do it.
3947

40-
In side your container, you can replace any of our code with your own to make it behave exactly as you wish. You could even create one dedicated shell per cluster with
41-
logic tailored specifically for that cluster.
48+
In side your container, you can replace any of our code with your own to make it behave exactly as you wish. You could even create one dedicated shell per cluster with logic tailored specifically for that cluster.
49+
50+
### Here are some other tips.
51+
52+
1. Many of our `Makefiles` do an `-include Makefile.*`, which means, we'll include other `Makefiles` in that directory. To add additional functionality, simply drop-in your `Makefile.something` in that directory.
4253

43-
Here are some other tips. Most of our modules do an `-include Makefile.*`, which means, we'll include other `Makefiles` in that directory. To add additional functionality,
44-
simply drop-in your `Makefile.something` in that module directory.
54+
2. Want to add additional aliases or affect the shell? Drop your script in `/etc/profile.d` and it will be loaded automatically when the shell starts.
4555

46-
Want to add additional aliases or affect the shell? Drop your script in `/etc/profile.d` and it will be loaded automatically when the shell starts.
56+
3. Need to set some environment variables? Use an `.envrc` in the corresponding directory
4757

4858
As you can see, you can easily change almost any aspect of how the shell works simply by extending it.
4959

docs/faq.md

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1-
# FAQ
1+
---
2+
title: FAQ(1) | Geodesic
3+
author:
4+
- Erik Osterman
5+
date: May 2019
6+
---
27

3-
## Does it work with Windows?
8+
## NAME
9+
10+
FAQ - Frequently Asked Questions
11+
12+
## QUESTIONS
13+
14+
### Does it work with Windows?
415

516
Yes! Geodesic runs on Windows 10, under the Windows Subsystem for Linux (WSL) for Ubuntu.
617

7-
## Error: Cannot list directory
18+
### Error: Cannot list directory
819

920
```
1021
$ ls /s3
@@ -13,19 +24,20 @@ ls: reading directory '.': I/O error
1324

1425
This means your AWS credentials have expired. Re-run `assume-role`.
1526

16-
## Error: Cannot unmount folder
27+
### Error: Cannot unmount folder
28+
1729
```bash
1830
$ s3 unmount
1931
umount: can't unmount /s3: Resource busy
2032
```
2133
2234
This means some process (maybe you) is in the directory. Try running `cd /` and rerun the unmount.
2335
24-
## What are the caveats?
36+
### What are the caveats?
2537
2638
* While the underlying tools support multiple cloud providers, we are currently only testing with AWS. Pull Requests welcome.
2739
28-
## Problems with `aws-vault`
40+
### Problems with `aws-vault`
2941
3042
Most problems are related to environment settings.
3143

docs/kops.md

+21-29
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
# Kubernetes Operations (kops)
1+
---
2+
title: KOPS(1) | Geodesic
3+
author:
4+
- Erik Osterman
5+
date: May 2019
6+
---
7+
8+
## NAME
9+
10+
kops - Kubernetes Operations (kops)
11+
12+
## SYNOPSIS
213

314
Kops is one of the easiest ways to get a production grade Kubernetes cluster up and running. The `kops` command line tool (cli) is like `kubectl` for clusters. It handles all the standard CRUD operations necessary to manage the complete life cycle of a cluster.
415

@@ -7,7 +18,8 @@ current practice is to define one cluster per Geodesic contianer, with all clust
718
in the `/conf` folder. We are planning to publish guidelines for how to manage multiple clusters per container,
819
but that is still a work in progress that will introduce some new patterns.
920

10-
### USAGE
21+
## DESCRIPTION
22+
1123
- This document describes how to set up a single `kops` cluster in a single Geodesic container.
1224
- The described usage pattern corresponds to [Geodesic](https://github.com/cloudposse/geodesic) version 0.95.1,
1325
[Reference Architecture](https://github.com/cloudposse/reference-architectures) version 0.7.0, and
@@ -18,27 +30,7 @@ of its publication. Also, because it is only updated manually (rather than gener
1830
be times when one part of this document intends to reference one version of a resource while another part references
1931
a different version. Please keep these facts in mind when you are using this document to help you set up your own cluster.
2032

21-
## Table of Contents
22-
23-
- [Kubernetes Operations (kops)](#kubernetes-operations-kops)
24-
- [Usage](#usage)
25-
- [Table of Contents](#table-of-contents)
26-
- [Features](#features)
27-
- [Overview](#overview)
28-
- [Configuration Settings Overview](#configuration-settings-overview)
29-
- [Terraform and Chamber](#terraform-and-chamber)
30-
- [Where Did That Value Come From?](#where-did-that-value-come-from)
31-
- [Create the Cluster](#create-the-cluster)
32-
- [Setting the Parameters](#setting-the-parameters)
33-
- [Shared VPC](#shared-vpc)
34-
- [Provisioning Resrouces](#provisioning-resources)
35-
- [Operating the Cluster](#operating-the-cluster)
36-
- [Tips & Tricks](#tips--tricks)
37-
- [Upgrade a Cluster](#upgrade-a-cluster)
38-
- [References](#references)
39-
- [Getting Help](#getting-help)
40-
41-
## Features
33+
## FEATURES
4234

4335
- **Automated Provisioning** of Kubernetes clusters in [AWS](https://github.com/kubernetes/kops/blob/master/docs/aws.md) and [GCE](https://github.com/kubernetes/kops/blob/master/docs/tutorial/gce.md)
4436
- **Highly Available (HA)** Kubernetes masters and nodes by using auto-scaling groups
@@ -50,7 +42,7 @@ a different version. Please keep these facts in mind when you are using this doc
5042
- **Supports Multiple CNIs** providers [out of the box](https://github.com/kubernetes/kops/blob/master/docs/networking.md).
5143
- **Lifecycle Hooks** make it easy to add containers and files to nodes via a [cluster manifest](https://github.com/kubernetes/kops/blob/master/docs/cluster_spec.md)
5244

53-
## Overview
45+
## OVERVIEW
5446

5547
The process of provisioning a new `kops` cluster takes (3) steps. Here's what it looks like:
5648

@@ -68,7 +60,7 @@ The process of provisioning a new `kops` cluster takes (3) steps. Here's what it
6860
- Validate the cluster is healthy.
6961

7062

71-
## Configuration Settings Overview
63+
### Configuration Settings Overview
7264

7365
We use 2 different mechanisms for storing configuration parameters.
7466

@@ -114,7 +106,7 @@ Normally `direnv` only reads the `.envrc` file, but CloudPosse adds a `use envrc
114106
causes `direenv` to read all the files in the directory that have `.envrc` extensions. This allows parameters
115107
to be set automatically by `direnv` without requiring that the settings be put in a hidden file.
116108

117-
##### `/conf/.direnv`
109+
##### `/conf/.envrc`
118110

119111
In the `/conf` directory itself, we put a file named `.envrc` which contains just this one line:
120112
```
@@ -196,7 +188,7 @@ SSM with the value from `kops.envrc`. This is why you should not set a parameter
196188

197189
</details>
198190

199-
## Create the cluster
191+
### Create the cluster
200192

201193
The following describes how to create a cluster, treating the setting of parameters in various places as
202194
steps in the creation process.
@@ -551,10 +543,10 @@ To upgrade the cluster or change settings (_e.g_. number of nodes, instance type
551543
8. Run `kops rolling-update cluster` to view a plan of changes
552544
9. Run `kops rolling-update cluster --yes --force` to force a rolling update (replace EC2 instances)
553545

554-
## References
546+
## REFERENCES
555547

556548
- https://github.com/kubernetes/kops/blob/master/docs/manifests_and_customizing_via_api.md
557549

558-
## Getting Help
550+
## GETTING HELP
559551

560552
Did you get stuck? Find us on [slack](https://slack.cloudposse.com) in the `#geodesic` channel.

docs/logo.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1-
## Our Logo
1+
---
2+
title: LOGO(1) | Geodesic
3+
author:
4+
- Erik Osterman
5+
date: May 2019
6+
---
7+
8+
## NAME
9+
10+
logo - Explanation of the Geodesic Logo
11+
12+
## SYNOPSIS
213

314
![Geodesic Logo](https://raw.githubusercontent.com/cloudposse/geodesic/master/docs/geodesic-small.png)
415

516
In mathematics, a geodesic line is the shortest distance between two points on a sphere. It's also a solid structure composed of geometric shapes such as hexagons.
617

18+
## DESCRIPTION
19+
720
We like to think of geodesic as the shortest path to a rock-solid cloud infrastructure. The geodesic logo is a hexagon with a cube suspended at its center. The cube represents this geodesic container, which is central to everything and at the same time is what ties everything together.
821

922
But look a little closer and you’ll notice there’s much more to it. It's also an isometric shape of a cube with a missing piece. This represents its pluggable design, which lets anyone extend it to suit their vision.

geodesic_apkindex.md5

-1
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
77e3cde7afac220dbf00e433fbaf4abb

packages.txt

+2
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ less
4141
libc6-compat
4242
libltdl
4343
make
44+
man-db@testing
4445
musl-dev
4546
ncurses
4647
oath-toolkit-oathtool@community
4748
openssh-client
4849
openssl
50+
pandoc@cloudposse
4951
pwgen
5052
python
5153
rakkess@cloudposse

rootfs/etc/profile.d/help.sh

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1+
# Use `man` page system for help
12
function help() {
2-
cat <<__EOF__
3-
Available commands:
4-
leave-role Leave the current role; run this to release your session
5-
assume-role Assume a new role; run this to renew your session
6-
setup-role Setup a new role; run this to configure your AWS profile
7-
s3 Manage s3 buckets with fstab
8-
init-terraform Configure terraform project backend to use S3
9-
10-
__EOF__
3+
if [ $# -ne 0 ]; then
4+
docs search --query="$*"
5+
else
6+
docs search
7+
fi
118
}

0 commit comments

Comments
 (0)