Skip to content

Commit b8e4219

Browse files
authored
Release 0.6.0 (#83)
* Modified docs Signed-off-by: niki-1905 <nikkikokitkar@gmail.com> * Remove jmeter submodule, literatebee key, and empty vendor folder. Signed-off-by: Arush Salil <me@aru.sh> * Update Dockerfile Signed-off-by: Arush Salil <me@aru.sh> * Update Readme Signed-off-by: Arush Salil <me@aru.sh> * Update AWS documentation Signed-off-by: Arush Salil <me@aru.sh> * Add lifecycle documentation. Signed-off-by: Arush Salil <me@aru.sh> * Fix typo Signed-off-by: Arush Salil <me@aru.sh> * Refactor and add tests Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * Update documentation * Update .gitignore * add pkg provisioner * Update Makefile * Release/0 5 1 (#74) * Update Documentation on master branch (#72) * Modified docs Signed-off-by: niki-1905 <nikkikokitkar@gmail.com> * Remove jmeter submodule, literatebee key, and empty vendor folder. Signed-off-by: Arush Salil <me@aru.sh> * Update Dockerfile Signed-off-by: Arush Salil <me@aru.sh> * Update Readme Signed-off-by: Arush Salil <me@aru.sh> * Update AWS documentation Signed-off-by: Arush Salil <me@aru.sh> * Add lifecycle documentation. Signed-off-by: Arush Salil <me@aru.sh> * Fix typo Signed-off-by: Arush Salil <me@aru.sh> * TK8-47 add infrastructure only flag https://kubernauts.atlassian.net/browse/TK8-47 * Bug/version (#75) * #67 | modify | remove not needed requirements Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * #66 | fix | Getting started link Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * #66 | modify | change path relative Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * Update Documentation on master branch (#72) * Modified docs Signed-off-by: niki-1905 <nikkikokitkar@gmail.com> * Remove jmeter submodule, literatebee key, and empty vendor folder. Signed-off-by: Arush Salil <me@aru.sh> * Update Dockerfile Signed-off-by: Arush Salil <me@aru.sh> * Update Readme Signed-off-by: Arush Salil <me@aru.sh> * Update AWS documentation Signed-off-by: Arush Salil <me@aru.sh> * Add lifecycle documentation. Signed-off-by: Arush Salil <me@aru.sh> * Fix typo Signed-off-by: Arush Salil <me@aru.sh> Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * Release/0 5 1 (#73) * Modified docs Signed-off-by: niki-1905 <nikkikokitkar@gmail.com> * Remove jmeter submodule, literatebee key, and empty vendor folder. Signed-off-by: Arush Salil <me@aru.sh> * Update Dockerfile Signed-off-by: Arush Salil <me@aru.sh> * Update Readme Signed-off-by: Arush Salil <me@aru.sh> * Update AWS documentation Signed-off-by: Arush Salil <me@aru.sh> * Add lifecycle documentation. Signed-off-by: Arush Salil <me@aru.sh> * Fix typo Signed-off-by: Arush Salil <me@aru.sh> * Refactor and add tests Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * Update documentation * Update .gitignore * add pkg provisioner * Update Makefile * TK8-47 add infrastructure only flag https://kubernauts.atlassian.net/browse/TK8-47 Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * BUG | Fix Version display The version is not display like accepted This will fix it Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * Add rke provisioner related variables Signed-off-by: Shantanu Deshpande <shantanud106@gmail.com> * RKE provisioner changes (#81) * Add documentation for using rke provisioner Signed-off-by: Shantanu Deshpande <shantanud106@gmail.com> * Add changes for rke provisioner configuration Signed-off-by: Shantanu Deshpande <shantanud106@gmail.com> * update the documentation add tk8 addon install rancher Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * move common stuff to the main pkg Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * Fix doc path rke Signed-off-by: Manuel Müller <mueller.m.h@gmail.com> * RKE region issue fix Signed-off-by: Shantanu Deshpande <shantanud106@gmail.com>
1 parent 73f114b commit b8e4219

File tree

9 files changed

+215
-9
lines changed

9 files changed

+215
-9
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
PROJECT := github.com/kubernauts/tk8
22
VERSION := $(shell git tag 2>/dev/null|tail -n 1)
33
GITCOMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
4-
BUILD_FLAGS := -ldflags="-w -X $(PROJECT)/cmd.GITCOMMIT=$(GITCOMMIT) -X $(PROJECT)/cmd.VERSION=$(VERSION)"
4+
BUILD_FLAGS := -ldflags "-w -s -X $(PROJECT)/pkg/common.GITCOMMIT=$(GITCOMMIT) -X $(PROJECT)/pkg/common.VERSION=$(VERSION)"
5+
6+
57

68
default: bin
79

cmd/cli/provisioner.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
eks "github.com/kubernauts/tk8-provisioner-eks"
2626
nutanix "github.com/kubernauts/tk8-provisioner-nutanix"
2727
openstack "github.com/kubernauts/tk8-provisioner-openstack"
28+
rke "github.com/kubernauts/tk8-provisioner-rke"
2829
"github.com/kubernauts/tk8/pkg/common"
2930
"github.com/kubernauts/tk8/pkg/provisioner"
3031

@@ -39,6 +40,7 @@ var provisioners = map[string]provisioner.Provisioner{
3940
"eks": eks.NewEKS(),
4041
"nutanix": nutanix.NewNutanix(),
4142
"openstack": openstack.NewOpenstack(),
43+
"rke": rke.NewRKE(),
4244
}
4345

4446
var provisionerInstallCmd = &cobra.Command{

cmd/cli/version.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package cmd
1616

1717
import (
1818
"fmt"
19-
19+
"github.com/kubernauts/tk8/pkg/common"
2020
"github.com/spf13/cobra"
2121
)
2222

@@ -32,8 +32,7 @@ var versionCmd = &cobra.Command{
3232
Short: "Print the version of TK8",
3333
Long: `All software has versions. This is TK8's`,
3434
Run: func(cmd *cobra.Command, args []string) {
35-
36-
fmt.Println("Version:" + VERSION + " (Build: " + GITCOMMIT + ")")
35+
fmt.Println("Version:" + common.VERSION + " (Build: " + common.GITCOMMIT + ")")
3736
},
3837
}
3938

config.yaml.example

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,14 @@ eks:
2727
node-instance-type: "m4.large"
2828
desired-capacity: 1
2929
autoscalling-max-size: 2
30-
autoscalling-min-size: 1
31-
key-file-path: "~/.ssh/id_rsa.pub"
30+
autoscalling-min-size: 1
31+
key-file-path: "~/.ssh/id_rsa.pub"
32+
33+
rke:
34+
cluster_name: "rke-tk8"
35+
node_os: "ubuntu"
36+
rke_aws_region: "us-east-2"
37+
authorization: "rbac"
38+
rke_node_instance_type: "t2.medium"
39+
node_count: 3
40+
cloud_provider: "aws"

docs/en/provisioner/introduction.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ Tk8 supports different platforms to provide a Kubernetes Cluster.
88
* [EKS](aws/introduction.md)
99
* [Baremetal](baremetal/introduction.md)
1010
* [Openstack](openstack/introduction.md)
11-
* [azure](azure/introduction.md)
12-
* [Nutanix](nutanix/introduction.md)
11+
* [RKE](rke/usage.md)
1312

1413
## Add own Provisioner
1514

docs/en/provisioner/rke/usage.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Using RKE (Rancher Kubernetes Engine) to provision kubernetes cluster with TK8
2+
3+
Provide the AWS credentials in following ways:
4+
5+
* [Environment Variables](https://docs.aws.amazon.com/cli/latest/userguide/cli-environment.html). You will need to specify `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_DEFAULT_REGION`.
6+
7+
## Prerequisites
8+
9+
* [Git](https://git-scm.com/)
10+
* [Terraform](https://www.terraform.io/downloads.html)
11+
* [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
12+
* [rke-cli](https://github.com/rancher/rke)
13+
* [terraform-provider-rke](https://github.com/yamamoto-febc/terraform-provider-rke)
14+
* Familiarity with rke configuration.
15+
16+
## Usage
17+
18+
### Install
19+
20+
* Modify values in `config.yaml.example` inside `rke` key. Supported options as of now:
21+
22+
```plain
23+
cluster_name - name of cluster
24+
node_os - operating system for nodes. Currently, ubuntu
25+
rke_aws_region - AWS region to install the cluster in.
26+
authorization - authorization in cluster. Possible values: `rbac`, `none`. Recommended is `rbac`
27+
rke_node_instance_type - instance type for nodes. t2.micro is highly discouraged.
28+
node_count - number of nodes to launch in cluster
29+
cloud_provisioner - cloud provisioner for rke cluster. Currently, only aws is supported.
30+
```
31+
32+
Example:
33+
34+
```yaml
35+
rke:
36+
cluster_name: "rke-tk8"
37+
node_os: ubuntu
38+
rke_aws_region: us-east-2
39+
authorization: "rbac"
40+
rke_node_instance_type: "t2.medium"
41+
node_count: 5
42+
cloud_provider: aws
43+
```
44+
45+
* After appropriate values are filled, run:
46+
47+
```shell
48+
tk8 cluster install rke
49+
```
50+
51+
Once the infrastructure and cluster is setup, `kubeconfig` file and `rancher-cluster.yml` file will be available at:
52+
53+
1. kubeconfig - `inventory/rke-tk8/provisioner/kube_config_cluster.yml`
54+
2. rancher config - `inventory/rke-tk8/provisioner/rancher-cluster.yml`
55+
56+
* Now you can use the same `kubeconfig` file to interact with kubernetes with kubectl and use `rancher-cluster.yml` to interact with cluster using `rke` cli.
57+
58+
> **Note**: Do not `mv` these files from this directory to somewhere else as these are stored in Terraform states. If required, make a copy.
59+
60+
### Remove
61+
62+
* For removing the rke cluster and keep the underlying infrastructure, run:
63+
64+
```shell
65+
tk8 cluster remove rke
66+
```
67+
68+
This is equivalent to `rke remove --config rancher-cluster.yml`.
69+
70+
### Destroy
71+
72+
* This will destroy the complete infrastructure. Run:
73+
74+
```shell
75+
tk8 cluster destroy rke
76+
```
77+
78+
> **Note** This is just a cluster provisioner, it will not install `rancher-2.x` on the cluster by itself. Use
79+
80+
```shell
81+
tk8 addon install rancher
82+
```
83+
84+
on the cluster.

pkg/common/main.go

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@ import (
66
"os"
77
"os/exec"
88
"path/filepath"
9+
10+
"github.com/spf13/viper"
911
)
1012

11-
var Name string
13+
var (
14+
Name string
15+
// GITCOMMIT will hold the commit SHA to be used in the version command.
16+
GITCOMMIT = "0"
17+
// VERSION will hold the version number to be used in the version command.
18+
VERSION = "dev"
19+
)
1220

1321
// ErrorCheck is responsbile to check if there is any error returned by a command.
1422
func ErrorCheck(msg string, err error) {
@@ -64,3 +72,31 @@ func GetFilePath(fileName string) string {
6472
cwd, _ := os.Getwd()
6573
return filepath.Join(cwd, fileName)
6674
}
75+
76+
// ReadViperConfigFile is define the config paths and read the configuration file.
77+
func ReadViperConfigFile(configName string) {
78+
viper.SetConfigName(configName)
79+
viper.AddConfigPath(".")
80+
viper.AddConfigPath("/tk8")
81+
verr := viper.ReadInConfig() // Find and read the config file.
82+
ErrorCheck("no config provided", verr)
83+
}
84+
85+
// AwsCredentials defines the structure to hold AWS auth credentials.
86+
type AwsCredentials struct {
87+
AwsAccessKeyID string
88+
AwsSecretKey string
89+
AwsAccessSSHKey string
90+
AwsDefaultRegion string
91+
}
92+
93+
// GetCredentials get the aws credentials from the config file.
94+
func GetCredentials() AwsCredentials {
95+
ReadViperConfigFile("config")
96+
return AwsCredentials{
97+
AwsAccessKeyID: viper.GetString("aws.aws_access_key_id"),
98+
AwsSecretKey: viper.GetString("aws.aws_secret_access_key"),
99+
AwsAccessSSHKey: viper.GetString("aws.aws_ssh_keypair"),
100+
AwsDefaultRegion: viper.GetString("aws.aws_default_region"),
101+
}
102+
}

pkg/templates/distos.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package templates
2+
3+
var DistVariablesRKE = `
4+
data "aws_ami" "distro" {
5+
most_recent = true
6+
7+
filter {
8+
name = "name"
9+
values = ["{{.NodeOS}}"]
10+
}
11+
12+
filter {
13+
name = "virtualization-type"
14+
values = ["hvm"]
15+
}
16+
17+
owners = ["{{.AmiOwner}}"]
18+
}
19+
20+
variable "ssh_user" {
21+
default = "{{.User}}"
22+
}
23+
`

pkg/templates/variables.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,58 @@
1414

1515
package templates
1616

17+
var VariablesRKE = `
18+
variable "cluster_name" {
19+
default = "{{.ClusterName}}"
20+
type = "string"
21+
description = "The name of your EKS Cluster"
22+
}
23+
24+
variable "authorization" {
25+
default = "{{.Authorization}}"
26+
type = "string"
27+
description = "Authorization mode for rke cluster"
28+
}
29+
30+
variable "rke_aws_region" {
31+
default = "{{.AWSRegion}}"
32+
# availabe regions are:
33+
# us-east-1 (Virginia)
34+
# us-west-2 (Oregon)
35+
# eu-west-1 (Irland)
36+
type = "string"
37+
description = "The AWS Region to deploy EKS"
38+
}
39+
40+
variable "rke_node_instance_type" {
41+
default = "{{.RKENodeInstanceType}}"
42+
type = "string"
43+
description = "Worker Node EC2 instance type"
44+
}
45+
46+
variable "node_count" {
47+
default = {{.NodeCount}}
48+
type = "string"
49+
description = "Autoscaling Desired node capacity"
50+
}
51+
variable "cloud_provider" {
52+
default = "{{.CloudProvider}}"
53+
type = "string"
54+
description = "cloud provider for rke cluster"
55+
}
56+
57+
variable "AWS_ACCESS_KEY_ID" {
58+
description = "AWS Access Key"
59+
}
60+
61+
variable "AWS_SECRET_ACCESS_KEY" {
62+
description = "AWS Secret Key"
63+
}
64+
65+
variable "AWS_DEFAULT_REGION" {
66+
description = "AWS Region"
67+
}
68+
`
1769
var VariablesEKS = `
1870
# Variables Configuration
1971
variable "cluster-name" {

0 commit comments

Comments
 (0)