Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit dca50d3

Browse files
committed
complete lab 7 pass 1
1 parent 2f54041 commit dca50d3

File tree

1 file changed

+67
-26
lines changed

1 file changed

+67
-26
lines changed

workshop/Lab7/README.md

Lines changed: 67 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Lab 7. Connecting to External Storage
2-
This lab configures our nodejs guestbook Application to connect to an external database - outside of the kubernetes cluster in which the guestbook app is deployed. For this lab we will be using a managed database service offered on IBM Cloud. The advantages of using a database service is that scaling, security, etc are often taken care of for you, but you can apply this lab to any external database service such as a legacy database you might have running on premise.
2+
This lab configures our nodejs guestbook Application to connect to an external database - outside of the kubernetes cluster in which the guestbook app is deployed. We will be using a managed database service offered on IBM Cloud. The advantages of using a database service is that scaling, security, etc are often taken care of for you, but you can apply this lab to any external database service such as a legacy database you might have running on premise.
3+
4+
Two options to setting up the database service
5+
- [Approach 1](#Approach-1:-Manually-create-database-service-on-IBM-Cloud-console)
6+
- [Approach 2](#-Approach-2:-Use-the-IBM-Cloud-Operator-to-provision-a-database-instance-on-IBM-Cloud)
37

48
## Approach 1: Manually create database service on IBM Cloud console
59

@@ -26,57 +30,95 @@ Expand the credential and take note of the **url** parameter. We will be using t
2630

2731
### Save your credentials in a Kubernetes `secret`
2832

29-
TODO `kubectl create url secret`
33+
```
34+
kubectl create secret generic cloudant-binding --from-literal=CLOUDANT_URL=[CLOUDANT_URL]
35+
```
3036

3137

3238
Once completed, [skip ahead to the next section](##Next-Steps)
3339

34-
## Approach 2: Use the IBM Cloud Operator to provision and manage the database instance on IBM Cloud
40+
## Approach 2: Use the IBM Cloud Operator to provision a database instance on IBM Cloud
3541

3642
The Operator Framework provides support for Kubernetes-native extensions to manage custom resource types through operators. Many operators are available through [operatorhub.io](https://operatorhub.io/), including the IBM Cloud operator. The IBM Cloud operator simplifies the creation of IBM Cloud services and resouces and binding credentials from these resources into a Kubernetes cluster. The instructions in this guide are adapted from the IBM Developer tutorial [Simplify the lifecycle management process for your Kubernetes apps with operators](https://developer.ibm.com/tutorials/simplify-lifecycle-management-kubernetes-openshift-ibm-cloud-operator/).
3743

3844
With the IBM Cloud Kubernetes Service clusters at version 1.16 and later, the Operator Framework is already installed. So all you will need to do is install the IBM Cloud Operator. New clusters created after March 1st, 2020 should all be at this level (or later).
3945

40-
### Installing the IBM Cloud operator
46+
### Create an API Key for your Target Account
4147

42-
1. With the OLM framework and marketplace support installed, it's time to install the IBM Cloud operator. This operator will use an IBM Cloud API key to manage resources within the cluster. Begin to configure the IBM Cloud operator by logging in to the IBM Cloud account using the IBM Cloud CLI. Start by logging in to IBM Cloud
48+
We will configure the IBM Cloud Operator to maange resources on your personal IBM Cloud Account. You will be able to create and manage a Cloudant DB lite service that only you will have access to.
4349

44-
```text
50+
1. Login to your personal IBM Cloud account. Use `--sso` if using single-sign-on. Select your personal account when asked upon logging in.
51+
52+
```
4553
ibmcloud login
4654
```
4755
48-
1. Check your login default region to verify that there is a Cloud Foundry organization and space with this command:
56+
```
57+
$ ibmcloud login
58+
API endpoint: https://cloud.ibm.com
59+
Region: us-south
60+
Authenticating...
61+
OK
62+
63+
Select an account:
64+
1. John H. Zaccone's Account (a21524842fc807640e69bf89c00009fc)
65+
2. Another Account (12345)
66+
Enter a number> 1
67+
Targeted account John H. Zaccone's Account (a21524842fc807640e69bf89c00009fc)
68+
69+
70+
API endpoint: https://cloud.ibm.com
71+
Region: us-south
72+
User: John.Zaccone@ibm.com
73+
Account: John H. Zaccone's Account (a21524842fc807640e69bf89c00009fc)
74+
Resource group: No resource group targeted, use 'ibmcloud target -g RESOURCE_GROUP'
75+
CF API endpoint:
76+
Org:
77+
```
4978
50-
```text
51-
ibmcloud account orgs
79+
1. Create a service ID in IBM Cloud IAM. If possible, do not use spaces in the names for your IAM credentials. When you use the operator binding feature, any spaces are replaced with underscores.
80+
81+
```
82+
ibmcloud iam service-id-create serviceid-ico
5283
```
5384
54-
If there is output like:
85+
1. Assign the service ID access to the required permissions to work with the IBM Cloud services. You will need the **Manager** role to provision a Cloudant service.
5586
56-
```text
57-
Getting orgs in region 'us-south' as myemail@example.com ...
58-
Retrieving current account...
59-
No organizations were found.
87+
```
88+
ibmcloud iam service-policy-create serviceid-ico --roles Manager --resource-group-name default --region us-south
6089
```
6190
62-
1. Verify that the ibmcloud CLI session is configured with a resource group for creation of the Tone Analyzer by the IBM Cloud operator. Run this command:
91+
1. Create an API key for the service ID.
6392
64-
```text
65-
ibmcloud target
93+
```
94+
ibmcloud iam service-api-key-create apikey-ico serviceid-ico
6695
```
6796
68-
Check the output from the `ibmcloud target` command. If there is no resource group set, resulting in a message including:
97+
1. Set the API key of the service ID as your CLI environment variable. Now, when you run the installation script, the script uses the service ID's API key. The following command is an example for macOS.
6998
70-
`Resource group: No resource group targeted, use 'ibmcloud target -g RESOURCE_GROUP'`
99+
```
100+
export IBMCLOUD_API_KEY=<apikey-ico-value>
101+
```
71102
72-
then set the target resource group to the `Default` using:
103+
1. Confirm that the API key environment variable is set in your CLI.
73104
74-
```text
75-
ibmcloud target -g Default
105+
```
106+
echo $IBMCLOUD_API_KEY
107+
```
108+
109+
### Installing the IBM Cloud operator
110+
111+
1. Follow the setup steps in [Lab0](../Lab0/README.md) if necessary to point your `kubectl` command-line tool to your Kubernetes cluster.
112+
113+
```shell
114+
ibmcloud login
76115
```
77116
78-
> some older IBM Cloud accounts may have a resource group named `default`, if you see an error using `Default`, repeat the command with `default`.
117+
1. Target the default resource group that your service ID has privledges to.
79118
119+
```text
120+
ibmcloud target -g default
121+
```
80122
81123
1. The operator marketplace catalog provides a URL for the resources to install for each operator. Install the IBM Cloud Operator with the following command:
82124
@@ -87,7 +129,7 @@ With the IBM Cloud Kubernetes Service clusters at version 1.16 and later, the Op
87129
Check that the pod for the IBM Cloud operator is running with:
88130
89131
```text
90-
kubectl get pods --namespace ibmcloud-operator-system
132+
kubectl get pods --namespace ibm-system
91133
```
92134
93135
You should see after a minute or two that the pod for the operator is running:
@@ -102,14 +144,13 @@ With the IBM Cloud Kubernetes Service clusters at version 1.16 and later, the Op
102144
103145
The [Operator Pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/) is an emerging approach to extend through automation the expertise of human operators into the cluster environment. Operators are intended to support applications and management of other resources in and related to kubernetes clusters starting at installation, but continuing to day 2 operations of monitoring, backup, fault recovery and, of course, updates.
104146
105-
![Operator Pattern](../.gitbook/assets/operator-pattern.png)
106-
107147
Operators are custom code that uses the Kubernetes API (as a client) to implement a controller for a [**Custom Resource**](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/). Unlike the controllers built into the Kubernetes control plane which run on the Kubernetes master node, operators run outside of the Kubernetes control plan as pods on the worker nodes in the cluster. You can verify that fact by the `kubectl get pods` command above, which lists the pods of the operator running on a worker node.
108148
109149
In addition to the IBM Cloud Operator, there are many operators that can manage resources within your cluster available from the [Operator Hub](https://operatorhub.io). The Operator Hub includes many useful operators including operators that implement database installation, monitoring tools, application development frameworks, application runtimes and more.
110150
111151
Your cluster now has the IBM Cloud operator installed. This operator is able to configure two custom resources in the cluster, a **Service** and a **Binding**. The **Service** defines a specific IBM Cloud service instance type to create, and the **Binding** specifies a named binding of a service instance to a secret in the cluster. For more details about the IBM Cloud operator see the [project repository](https://github.com/IBM/cloud-operators)
112152
153+
<br>
113154
114155
### Creating an instance of Cloudant
115156

0 commit comments

Comments
 (0)