Skip to content

Commit 3fcb582

Browse files
marinakogrjeberhard
authored andcommitted
removed code for building terraform oci provider, added copiright info, corrected typos
1 parent 0f953d5 commit 3fcb582

File tree

11 files changed

+192
-167
lines changed

11 files changed

+192
-167
lines changed

kubernetes/samples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ While these samples may be useful and usable as is, it is intended that you woul
1414
* [Sample for creating a WebLogic domain home inside a Docker image](scripts/create-weblogic-domain/domain-home-in-image/README.md), and the domain resource YAML file for deploying the generated WebLogic domain.
1515
* [Sample for configuring the Elasticsearch and Kibana](scripts/elasticsearch-and-kibana/README.md) deployments and services for the operator's logs.
1616
* [Sample for generating a self-signed certificate and private key](scripts/rest/README.md) that can be used for the operator's external REST API.
17-
* [Sample for generating OKE cluster using Terraform](scripts/terraform/README.md).
17+
* [Sample for creating an OKE cluster using Terraform](scripts/terraform/README.md).
1818

1919
## Sample Helm charts
2020

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,62 @@
1-
# Sample to create OKE cluster using Terraform scripts
1+
# Sample to create an OKE cluster using Terraform scripts
22

33
The provided sample will create:
44

55
A new Virtual Cloud Network (VCN) for the cluster
66

7-
2 LoadBalancer subnets with seclists
7+
Two LoadBalancer subnets with security lists
88

9-
3 Worker subnets with seclists
9+
Three Worker subnets with security lists
1010

11-
A Kubernetes Cluster with one NodePool
11+
A Kubernetes Cluster with one Node Pool
1212

13-
A kubeconfig file to allow access using kubectl
13+
A `kubeconfig` file to allow access using `kubectl`
1414

15-
Nodes and network settings will be configured to allow SSH access, and the cluster Networking policies will allow NodePort services to be exposed.
15+
Nodes and network settings will be configured to allow SSH access, and the cluster networking policies will allow `NodePort` services to be exposed. This cluster can be used for testing and development purposes only. The provided samples of Terraform scripts should not be considered for creating production clusters, without more of a review.
1616

17-
By default all OCI Container Engine for Kubernetes Cluster masters are Highly Available (HA) and fronted by load balancers.
17+
All OCI Container Engine masters are Highly Available (HA) and fronted by load balancers.
1818

1919

2020

21-
Prerequisites
21+
###Prerequisites
2222

2323
To use these Terraform scripts, you will need fulfill the following prerequisites:
2424

25-
Have an existing tenancy with enough compute and networking resources available for the desired cluster
25+
Have an existing tenancy with enough compute and networking resources available for the desired cluster.
2626

27-
Have an OCI Container Engine for Kubernetes policy in place within that tenancy to allow the OCI Container Engine for Kubernetes service to manage tenancy resources
27+
Have an [Identity and Access Management](https://docs.cloud.oracle.com/iaas/Content/ContEng/Concepts/contengpolicyconfig.htm#PolicyPrerequisitesService) policy in place within that tenancy to allow the OCI Container Engine for Kubernetes service to manage tenancy resources.
2828

29-
Install Terraform with the OCI plugin as described here.
29+
Have a user defined within that tenancy.
3030

31-
Have a user defined within that tenancy
31+
Have an API key defined for use with the OCI API, as documented [here](https://docs.cloud.oracle.com/iaas/Content/Identity/Tasks/managingcredentials.htm).
3232

33-
Have an API key defined for use with the OCI API, as documented here
33+
Have an [SSH key pair](https://docs.oracle.com/en/cloud/iaas/compute-iaas-cloud/stcsg/generating-ssh-key-pair.html) for configuring SSH access to the nodes in the cluster.
3434

35-
Have an SSH key pair with file permission 600 ready for configuring SSH access to the nodes in the cluster
3635

36+
Copy provided `oci.props.template` file to `oci.props` and add all required values:
37+
* `user.ocid` - OCID for the tenancy user - can be obtained from the user settings in the OCI console.
38+
* `tfvars.filename` - File name for generated tfvar file.
39+
* `okeclustername` - The name for OCI Container Engine for Kubernetes cluster.
40+
* `tenancy.ocid` - OCID for the target tenancy.
41+
* `region` - name of region in the target tenancy.
42+
* `compartment.ocid` - OCID for the target compartment.
43+
* `compartment.name` - Name for the target compartment.
44+
* `ociapi.pubkey.fingerprint` - Fingerprint of the OCI user's public key.
45+
* `ocipk.path` - API Private Key -- local path to the private key for the API key pair.
46+
* `vcn.cidr.prefix` - Prefix for VCN CIDR, used when creating subnets -- you should examine the target compartment find a CIDR that is available.
47+
* `vcn.cidr` - Full CIDR for the VCN, must be unique within the compartment, first 2 octets should match the vcn_cidr_prefix.
48+
* `nodepool.shape` - A valid OCI VM Shape for the cluster nodes.
49+
* `k8s.version` - SSH public key (key contents as a string).
50+
* `nodepool.imagename - A valid image name for Node Pool creation.
51+
* `terraform.installdir` - Location to install Terraform binaries.
3752

38-
Copy provided oci.props.template file to oci.props and add all required values.
39-
40-
The syntax of the script is:
53+
To run the script, use the command:
4154
```
4255
$ kubernetes/samples/scripts/terraform/oke.create.sh oci.props
4356
```
44-
The scripts collects the values from oci.props file and performs the following steps:
45-
Create a new tfvars file based on the values from the provided oci.props file.
46-
Downloads and installs all needed binaries for Terraform, Terraform OCI Provider and Go, based on OS system ( Mac or Linux)
47-
Apply the configuration and creates OKE Cluster using Terraform
57+
The script collects the values from `oci.props` file and performs the following steps:
58+
* Creates a new tfvars file based on the values from the provided `oci.props` file.
59+
* Downloads and installs all needed binaries for Terraform, Terraform OCI Provider, based on OS system (macOS or Linux)
60+
* Applies the configuration and creates OKE Cluster using Terraform
4861

4962

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1-
variable "cluster_kubernetes_version" { default = "v1.10.3" }
1+
/*
2+
# Copyright 2018, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
4+
*/
5+
variable "cluster_kubernetes_version" { default = "v1.11.5" }
26
variable "cluster_name" { default = "tfTestCluster" }
37
variable "cluster_options_add_ons_is_kubernetes_dashboard_enabled" { default = true }
48
variable "cluster_options_add_ons_is_tiller_enabled" { default = true }
59
variable "cluster_options_kubernetes_network_config_pods_cidr" { default = "10.1.0.0/16" }
610
variable "cluster_options_kubernetes_network_config_services_cidr" { default = "10.2.0.0/16" }
711
variable "node_pool_initial_node_labels_key" { default = "key" }
812
variable "node_pool_initial_node_labels_value" { default = "value" }
9-
variable "node_pool_kubernetes_version" { default = "v1.10.3" }
13+
variable "node_pool_kubernetes_version" { default = "v1.11.5" }
1014
variable "node_pool_name" { default = "tfTestCluster_workers" }
1115
variable "node_pool_node_image_name" { default = "Oracle-Linux-7.4" }
12-
variable "node_pool_node_shape" { default = "VM.Standard1.1" }
16+
variable "node_pool_node_shape" { default = "VM.Standard2.1" }
1317
variable "node_pool_quantity_per_subnet" { default = 2 }
1418
variable "node_pool_ssh_public_key" { }
1519

16-
data "oci_identity_availability_domains" "test_availability_domains" {
20+
data "oci_identity_availability_domains" "tfsample_availability_domains" {
1721
compartment_id = "${var.compartment_ocid}"
1822
}
1923

20-
// Defined in oke.tf
21-
/*resource "oci_core_virtual_network" "oke-vcn" {
22-
cidr_block = "${var.vcn_cidr}"
23-
compartment_id = "${var.compartment_ocid}"
24-
display_name = "${var.cluster_name}_vcn"
25-
}*/
2624

27-
resource "oci_containerengine_cluster" "test_cluster" {
25+
resource "oci_containerengine_cluster" "tfsample_cluster" {
2826
#Required
2927
compartment_id = "${var.compartment_ocid}"
3028
kubernetes_version = "${var.cluster_kubernetes_version}"
@@ -41,17 +39,12 @@ resource "oci_containerengine_cluster" "test_cluster" {
4139
is_kubernetes_dashboard_enabled = "${var.cluster_options_add_ons_is_kubernetes_dashboard_enabled}"
4240
is_tiller_enabled = "${var.cluster_options_add_ons_is_tiller_enabled}"
4341
}
44-
#kubernetes_network_config {
45-
#Optional
46-
#pods_cidr = "${var.cluster_options_kubernetes_network_config_pods_cidr}"
47-
#services_cidr = "${var.cluster_options_kubernetes_network_config_services_cidr}"
48-
#}
4942
}
5043
}
5144

52-
resource "oci_containerengine_node_pool" "test_node_pool" {
45+
resource "oci_containerengine_node_pool" "tfsample_node_pool" {
5346
#Required
54-
cluster_id = "${oci_containerengine_cluster.test_cluster.id}"
47+
cluster_id = "${oci_containerengine_cluster.tfsample_cluster.id}"
5548
compartment_id = "${var.compartment_ocid}"
5649
kubernetes_version = "${var.node_pool_kubernetes_version}"
5750
name = "${var.node_pool_name}"
@@ -60,16 +53,10 @@ resource "oci_containerengine_node_pool" "test_node_pool" {
6053
subnet_ids = ["${oci_core_subnet.oke-subnet-worker-1.id}", "${oci_core_subnet.oke-subnet-worker-2.id}","${oci_core_subnet.oke-subnet-worker-3.id}"]
6154

6255
#Optional
63-
#initial_node_labels {
64-
65-
#Optional
66-
# key = "${var.node_pool_initial_node_labels_key}"
67-
# value = "${var.node_pool_initial_node_labels_value}"
68-
#}
6956
quantity_per_subnet = "${var.node_pool_quantity_per_subnet}"
7057
ssh_public_key = "${var.node_pool_ssh_public_key}"
7158
}
7259

7360
output "cluster_id" {
74-
value = "${oci_containerengine_cluster.test_cluster.id}"
61+
value = "${oci_containerengine_cluster.tfsample_cluster.id}"
7562
}
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
/*
2+
# Copyright 2018, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
4+
*/
5+
16
variable "cluster_kube_config_expiration" { default = 2592000 }
27
variable "cluster_kube_config_token_version" { default = "1.0.0" }
38

4-
data "oci_containerengine_cluster_kube_config" "test_cluster_kube_config" {
9+
data "oci_containerengine_cluster_kube_config" "tfsample_cluster_kube_config" {
510
#Required
6-
cluster_id = "${oci_containerengine_cluster.test_cluster.id}"
7-
8-
#Optional
9-
#expiration = "${var.cluster_kube_config_expiration}"
10-
#token_version = "${var.cluster_kube_config_token_version}"
11+
cluster_id = "${oci_containerengine_cluster.tfsample_cluster.id}"
1112
}
1213

13-
resource "local_file" "test_cluster_kube_config_file" {
14-
content = "${data.oci_containerengine_cluster_kube_config.test_cluster_kube_config.content}"
14+
resource "local_file" "tfsample_cluster_kube_config_file" {
15+
content = "${data.oci_containerengine_cluster_kube_config.tfsample_cluster_kube_config.content}"
1516
filename = "${path.module}/${var.cluster_name}_kubeconfig"
1617
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
user.ocid=ocid1.user.oc1..aaaaaaaast7s6jdho6mh2dqvyqcychofaiv5lhztkx7u5jlr5wwuhhmewq
2+
okeclustername=myokecluster
3+
tfvars.filename=myokeclustertf
4+
region=us-phoenix-1
5+
tenancy.ocid=ocid1.tenancy.oc1..aaaaaahmcbb5mp2h6toh4vj7ax526xtmihrneoumyat557rvlolsx63imq
6+
compartment.ocid=ocid1.compartment.oc1..aaaaaaaaxzwkinzejhkncuvfy67pmb6wb46ifrixtuikkrgnnrp4wswsu4xq
7+
compartment.name=QualityAssurance
8+
ociapi.pubkey.fingerprint=c8\:b2\:da\:b2\:e8\:96\:7e\:bf\:ac\:ee\:ce\:bc\:a8\:7f\:07\:c5
9+
ocipk.path=/scratch/mkogan/.oci/oci_api_key.pem
10+
vcn.cidr.prefix=10.1
11+
vcn.cidr=10.1.0.0/16
12+
nodepool.shape=VM.Standard2.1
13+
nodepool.imagename=Oracle-Linux-7.4
14+
k8s.version=v1.10.11
15+
nodepool.ssh.pubkey=ssh-rsa AAAAB3NzaC1yc2EAAAAQABAAABAQC9FSfGdjjL+EZre2p5yLTAgtLsnp49AUVX1yY9V8guaXHol6UkvJWnyFHhL7s0qvWj2M2BYo6WAROVc0/054UFtmbd9zb2oZtGVk82VbT6aS74cMlqlY91H/rt9/t51Om9Sp5AvbJEzN0mkI4ndeG/5p12AUyg9m5XOdkgI2n4J8KFnDAI33YSGjxXb7UrkWSGl6XZBGUdeaExo3t2Ow8Kpl9T0Tq19qI+IncOecsCFj1tbM5voD8IWE2l0SW7V6oIqFJDMecq4IZusXdO+bPc+TKak7g82RUZd8PARpvYB5/7EOfVadxsXGRirGAKPjlXDuhwJYVRj1+IjZ+5Suxz mkogan@slc13kef
16+
terraform.installdir=/scratch/mkogan/myterraformtest
17+
Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,45 @@
1+
# Copyright 2018, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
4+
# Properties to generate TF variables file for cluster creation from property file oci.props
5+
#
6+
# Copy this file to oci.props and update it with your own info, see oci.props.example as sample for values
7+
#
8+
9+
# OCID can be obtained from the user info page in the OCI console
110
user.ocid=
11+
12+
# name of OKE cluster
213
okeclustername=
14+
15+
# name of tfvars file (no extention) to generate
316
tfvars.filename=
17+
18+
# Required tenancy info
419
tenancy.ocid=
520
compartment.ocid=
621
compartment.name=
22+
region=
23+
24+
# API key fingerprint and private key location, needed for API access -- you should have added a public API key through the OCI console first, add escape backslash \ for each colon signt
725
ociapi.pubkey.fingerprint=
26+
27+
# path to private OCI API key
828
ocipk.path=
29+
30+
# VCN CIDR -- must be unique within the compartment in the tenancy
31+
# - assuming 1:1 cluster:vcn
32+
# BE SURE TO SET BOTH VARS -- the first 2 octets for each variable have to match
933
vcn.cidr.prefix=
1034
vcn.cidr=
35+
36+
# Node pool info
1137
nodepool.shape=
12-
k8s.version=
1338
nodepool.ssh.pubkey=
14-
terraform.installdir=
15-
go.installdir=
39+
nodepool.imagename=
1640

41+
# K8S version
42+
k8s.version=
43+
44+
#location for terraform installation
45+
terraform.installdir=

0 commit comments

Comments
 (0)