go get gopkg.in/yaml.v2
Currently can bring up kubernetes cluster in CNCT maas lab or on aws.
You will need to set the instance of Juju
with the following fields:
In order to run the juju cli in discrete environments, a different JUJU_DATA path is set per
Juju.Name. This path prefix defaults to /tmp
and will result in the loss of the juju cli
state as /tmp is ephemeral.
Set this variable to a path with persistant storage:
import (
"github.com/dstorck/gogo"
)
gogo.JujuDataPrefix = "/data"
- Note - While several fields are optional, you must include either
MaasCl
andMaasCr
orAwsCl
andAwsCr
Field Name | Required | Type | Description |
---|---|---|---|
Kind | Required | CloudKind | must use one of the const: Maas or Aws |
Name | Required | String | JUJU_DATA path and juju clustername for MAAS |
Bundle | Required | String | ex "cs:bundle/canonical-kubernetes-193" |
p | Optional | Parallel | used for multiple cluster creation |
MaasCl | Optional | MaasCloud | maas cloud details |
MaasCr | Optional | MaasCredentials | maas credential details |
AwsCl | Optional | AwsCloud | aws cloud details |
AwsCr | Optional | AwsCredentials | aws credential details |
Field Name | Required | Type | Description |
---|---|---|---|
Endpoint | Required | String | maas url ex-"http://your-ip/MAAS/api/2.0" |
Field Name | Required | Type | Description |
---|---|---|---|
Username | Required | String | maas username |
MaasOauth | Required | String | maas api key |
Field Name | Required | Type | Description |
---|---|---|---|
Region | Optional | String | ex "aws/us-west-2" |
Field Name | Required | Type | Description |
---|---|---|---|
Username | Required | String | your aws username |
AccessKey | Required | String | aws access key |
SecretKey | Required | String | aws secret key |
SetAWSCreds()
- sets aws credentials for use with jujuSetMAASCreds()
sets maas credentials for use with jujuSetMAASCloud()
- sets maas cloud information for use with jujuSpinup()
- spins up cluster from specified creds/cloud/bundle (includes setting cloud and credentials)ControllerReady()
- returns boolean with status of controller availabilityGetStatus()
- returns result of running juju statusClusterReady()
- returns boolean corresponding to readiness of clusterGetKubeConfig()
- returns the contents of the kubeconfig fileDestroyCluster()
- tears down juju controller and associated clusterDestroyComplete()
returns boolean corresponding to successful destruction of cluster
package main
import (
"fmt"
"github.com/dstorck/gogo"
)
var testRun = gogo.Juju{
Kind: gogo.Maas,
Name: "test-cluster",
Bundle: "cs:bundle/kubernetes-core-306",
MaasCl: myMaasCloud,
MaasCr: myMaasCreds,
}
var myMaasCloud = gogo.MaasCloud{
Endpoint: "<your-maas-url>",
}
var myMaasCreds = gogo.MaasCredentials{
Username: "<username>",
MaasOauth: "<maas-api-key>",
}
// current available commands, not meant to be run all at once
func main() {
testRun.SetMAASCreds()
testRun.SetMAASCloud()
testRun.Spinup()
status, _ := testRun.GetStatus()
fmt.Println(status)
testRun.ClusterReady()
config,_ := testRun.GetKubeConfig()
fmt.Println(string(config))
testRun.DestroyCluster()
testRun.DestroyComplete()
}
package main
import (
"github.com/dstorck/gogo"
)
var testRun = gogo.Juju{
Kind: gogo.Aws,
Name: "test-cluster",
Bundle: "cs:bundle/kubernetes-core-306",
AwsCr: myAWScreds,
AwsCl: myAWScloud,
}
var myAWScreds = gogo.AWSCredentials{
Username: "<your-aws-username>",
AccessKey: "<your-access-key>",
SecretKey: "<your-secret-key",
}
var myAWScloud = gogo.AWSCloud{
Region: "aws/us-west-2",
}
// currently available commands, not meant to be run all at once
func main() {
// testRun.SetAWSCreds()
// testRun.GetStatus()
// testRun.Spinup()
// testRun.ControllerReady()
// testRun.ClusterReady()
// testRun.GetKubeConfig()
// testRun.DestroyCluster()
// testRun.DestroyComplete()
}