Skip to content

Commit

Permalink
[terraform] close #1
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas2lee committed Dec 7, 2019
1 parent c14a932 commit 91a038a
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ignore intellig config
.idea

**.iml
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
# streaming-ibmcloud-workshop
# streaming-ibmcloud-workshop

## prerequisite
* ibmcloud cli
* ibmcloud plugin container-service container-reigstry
* docker
* kubernetes
* helm
* terraform
* terraform ibm cloud plugin

### play with kube
* docker, kubernete preinstalled
* use /env/install.sh to install the rest

## login with your ibm cloud account
ibmcloud login (--sso(according to your case))

## provision your needed ibm cloud service with terraform (is possible)

1. create api key for terraform

ibmcloud iam api-key-create <api-key-name> -d 'ibmcloud api key for terraform' --file ibmcloud_apikey.json
1. create static tf variables

provider.tf
```hcl-terraform
provider "ibm" {
ibmcloud_api_key = "<api-key>"
}
```
### kubernetes cluster
### namespace for docker registry
### toolchain
30 changes: 30 additions & 0 deletions env/play-with-kube/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#bin/bash
#========== install ibmcloud standalone cli ==========
#========== ref doc: https://cloud.ibm.com/docs/cli?topic=cloud-cli-install-ibmcloud-cli&locale=en-us
curl -fsSL https://clis.cloud.ibm.com/install/linux | sh

#========== install ibmcloud plugin container-service, container-registry ==========
ibmcloud plugin install container-service
ibmcloud plugin install container-registry

#========== install helm ==========
#========== ref doc: https://helm.sh/docs/intro/install/ ==========
yum install -y openssl which
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 > get_helm.sh
chmod 700 get_helm.sh
./get_helm.sh


#========== install terraform ==========
#========== ref doc: https://developer.ibm.com/recipes/tutorials/infrastructure-automation-with-terraform-on-ibm-cloud-iaas/ ==========
yum install -y wget unzip
wget https://releases.hashicorp.com/terraform/0.12.17/terraform_0.12.17_linux_amd64.zip
unzip terraform_0.12.17_linux_amd64.zip
mv terraform /usr/local/bin/terraform

#========== install terraform ibm cloud provider==========
#========== ref doc: https://github.com/IBM-Cloud/terraform-provider-ibm/releases ==========
wget https://github.com/IBM-Cloud/terraform-provider-ibm/releases/download/v1.0.0/linux_amd64.zip
mkdir -p $HOME/.terraform.d/plugins
unzip linux_amd64.zip
mv terraform-provider-ibm_v1.0.0 $HOME/.terraform.d/plugins/terraform-provider-ibm_v1.0.0
6 changes: 6 additions & 0 deletions terraform/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ignore secrets
ibmcloud_apikey.json

#ignore terraform files
**/.terraform
terraform/tfstate**
17 changes: 17 additions & 0 deletions terraform/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# provision your needed ibm cloud service with terraform (is possible)

1. create api key for terraform

ibmcloud iam api-key-create <api-key-name> -d 'ibmcloud api key for terraform' --file ibmcloud_apikey.json
1. create static tf variables

provider.tf
```hcl-terraform
provider "ibm" {
ibmcloud_api_key = "<api-key>"
}
```
[Terrafrom ibm cloud doc ref](https://ibm-cloud.github.io/tf-ibm-docs/index.html#using-terraform-with-the-ibm-cloud-provider)
## kubernetes cluster
## namespace for docker registry
## toolchain
7 changes: 7 additions & 0 deletions terraform/streaming/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "ibm_container_cluster" "streaming_kubernetes_cluster" {
name = "streaming"
datacenter = "dal10"
machine_type = "free"
hardware = "shared"

}
3 changes: 3 additions & 0 deletions terraform/streaming/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "ibm" {
ibmcloud_api_key = "<api-key>"
}

0 comments on commit 91a038a

Please sign in to comment.