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

Commit 10c6090

Browse files
authored
Merge pull request #4 from IBM/master
Synching vwilburn fork
2 parents 09a7f48 + 2ecaa8a commit 10c6090

File tree

5 files changed

+69
-439
lines changed

5 files changed

+69
-439
lines changed

Lab 0/README.md

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
# Lab 0: Getting the IBM Cloud Container Service
22

33

4-
Before you begin learning, you will need to install the required CLIs to create and manage your Kubernetes clusters in IBM Cloud Container Service, and to deploy containerized apps to your cluster.
4+
Before you begin learning, you need to install the required CLIs to create and manage your Kubernetes clusters in IBM Cloud Container Service and to deploy containerized apps to your cluster.
55

66
This lab includes the information for installing these CLIs and plug-ins:
77

88

99
``` txt
1010
IBM Cloud CLI version 0.5.0 or later
1111
IBM Cloud Container Service plug-in
12-
Kubernetes CLI version 1.5.6 or later
12+
Kubernetes CLI version 1.7.4 or later
1313
Optional: IBM Cloud Container Registry plug-in
1414
Optional: Docker version 1.9. or later
1515
```
1616

1717
If you have the CLIs and plug-ins, you can skip this lab and proceed to the next one.
1818

19-
2019
To install the CLIs:
2120

2221
As a prerequisite for the IBM Cloud Container Service plug-in, install the IBM Cloud command-line interface, located at https://clis.ng.bluemix.net/ui/home.html. Once installed, you can access IBM Cloud from your command-line with the prefix `bx`.
2322

2423
Log in to the IBM Cloud CLI with `bx login`. Enter your IBM Cloud credentials when prompted.
2524

26-
27-
2825
Note: If you have a federated ID, use `bx login --sso` to log in to the IBM Cloud CLI. Enter your user name and use the provided URL in your CLI output to retrieve your one-time passcode. You know you have a federated ID when the login fails without the `--sso` and succeeds with the `--sso` option.
2926

3027
# Install the IBM Cloud Container Service plug-in
@@ -41,31 +38,31 @@ The IBM Cloud Container Service plug-in is displayed in the results as `containe
4138

4239
To view a local version of the Kubernetes dashboard and to deploy apps into your clusters, you will need to install the Kubernetes CLI. The following links will install the CLI. Simply click the link corresponding to your operating system:
4340

44-
OS X: https://storage.googleapis.com/kubernetes-release/release/v1.5.6/bin/darwin/amd64/kubectl
45-
Linux: https://storage.googleapis.com/kubernetes-release/release/v1.5.6/bin/linux/amd64/kubectl
46-
Windows: https://storage.googleapis.com/kubernetes-release/release/v1.5.6/bin/windows/amd64/kubectl.exe
41+
OS X: https://storage.googleapis.com/kubernetes-release/release/v1.7.4/bin/darwin/amd64/kubectl
42+
Linux: https://storage.googleapis.com/kubernetes-release/release/v1.7.4/bin/linux/amd64/kubectl
43+
Windows: https://storage.googleapis.com/kubernetes-release/release/v1.7.4/bin/windows/amd64/kubectl.exe
4744

4845
Tip: If you are using Windows, install the Kubernetes CLI in the same directory as the IBM Cloud CLI. This setup saves you some filepath changes when you run commands later.
4946

50-
For OSX and Linux users, complete the following steps.
47+
For OSX and Linux users, complete the following steps:
5148

52-
Move the executable file to the `/usr/local/bin` directory with `mv /<path_to_file>/kubectl /usr/local/bin/kubectl` .
49+
1. Move the executable file to the `/usr/local/bin` directory with `mv /<path_to_file>/kubectl /usr/local/bin/kubectl` .
5350

54-
Make sure that `/usr/local/bin` is listed in your PATH system variable.
51+
2. Make sure that `/usr/local/bin` is listed in your PATH system variable.
5552

56-
```txt
57-
echo $PATH
58-
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
59-
```
60-
Convert the binary file to an executable. `chmod +x /usr/local/bin/kubectl`
53+
```txt
54+
echo $PATH
55+
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
56+
```
6157

62-
# Download the Container Registry Plugin
58+
3. Convert the binary file to an executable. `chmod +x /usr/local/bin/kubectl`
6359

64-
To manage a private image repository, install the Cloud Container Registry plug-in. Use this plug-in to set up your own namespace in a multi-tenant, highly available, and scalable private image registry that is hosted by IBM, and to store and share Docker images with other users. Docker images are required to deploy containers into a cluster. The prefix for running registry commands is bx cr.
60+
# Download the IBM Cloud Container Registry plug-in
6561

62+
To manage a private image repository, install the IBM Cloud Container Registry plug-in. Use this plug-in to set up your own namespace in a multi-tenant, highly available, and scalable private image registry that is hosted by IBM, and to store and share Docker images with other users. Docker images are required to deploy containers into a cluster. The prefix for running registry commands is `bx cr`.
6663

6764
`bx plugin install container-registry -r Bluemix`
6865
To verify that the plug-in is installed properly, run`bx plugin list`
6966
The plug-in is displayed in the results as `container-registry`.
7067

71-
To build images locally and push them to your registry namespace, install Docker If you are using Windows 8 or earlier, you can install the Docker Toolbox External link icon instead. The Docker CLI is used to build apps into images. The prefix for running commands by using the Docker CLI is docker.
68+
To build images locally and push them to your registry namespace, [install Docker](https://www.docker.com/community-edition#/download). The Docker CLI is used to build apps into images. The prefix for running commands by using the Docker CLI is `docker`.

Lab 4/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# Highly Available Deployments with IBM Cloud Container Service
1+
# Highly available deployments with IBM Cloud Container Service
22

3-
The goal of this lab is to begin to understand how to deploy a highly available application. It's easier than many think, but can be expensive if deploying across multiple AZs. The example in this lab shows how to deploy an application across two worker nodes in the same AZ (a basic level of high availability, to explore the concepts).
3+
The goal of this lab is to learn how to deploy a highly available application. It's easier than many think but can be expensive if deploying across multiple availability zones. In order to explore the concepts, this lab shows how to deploy an application across two worker nodes in the same availability zone, which is a basic level of high availability.
44

5-
# Federated Kubernetes Cluster: Two Worker Nodes Running the Same Application
5+
# Federated Kubernetes cluster: Two clusters running the same application
66

7-
To get started, create a paid cluster with two workers and wait for it to provision.
7+
To get started, create a paid cluster with two workers and wait for it to provision. If this is your first paid cluster, then you do not need to specify the public vlan and the private vlan.
88

9-
`bx cs cluster-create --name Cluster02 --machine-type b1c.4x16 --location dal10 --workers 2 --public-vlan 1900401 --private-vlan 1900403 --location dal10`
9+
`bx cs cluster-create --name <cluster-name> --machine-type b2c.4x16 --location <location> --workers 2 --public-vlan <public-vlan> --private-vlan <private-vlan>`
1010

11-
While waiting, you need to download kubefed, which will allow you to set up a kubernetes federated cluster.
11+
While waiting, you need to download kubefed, which will allow you to set up a Kubernetes federated cluster.
1212
As this is for lab purposes only, we will be using an IBM liberty image as a basic template for an imaged application.
1313

1414
Download the kubefed tarfile using curl:
@@ -44,7 +44,7 @@ You’ll need to provide the kubeconfig context (called name in the entry above)
4444

4545
At this time, export the kubeconfig file for the admin user of the cluster using `bx cs cluster-config <nameOfCluster> --admin`, make a note of it for error handling later.
4646

47-
# Deploy a Federation Control Plane
47+
# Deploy a federation control plane
4848

4949
To deploy a federation control plane on your host cluster, run `kubefed init` command. When you use `kubefed init`, you must provide the following:
5050

@@ -150,7 +150,7 @@ Creating a namespace federation-system for federation system components... done
150150
Creating federation control plane service......
151151
```
152152

153-
# Deploying an Application to a Federated Cluster
153+
# Deploying an application to a federated cluster
154154

155155

156156
The API for Federated Deployment is compatible with the API for traditional Kubernetes Deployment. You can create a Deployment by sending a request to the federation data layer.

Lab 5/README.md

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
# Security with IBM Cloud Container Service
22

3+
This lab is intended to introduce a user to Kubernetes-specific security features used to limit the attack surface and harden your cluster against network threats. You can use built-in security features for risk analysis and security protection. These features help you protect your cluster infrastructure and network communication, isolate your compute resources, and ensure security compliance across your infrastructure components and container deployments.
34

4-
This lab is intended to introduce a user to kubernetes-specific security features used to limit the attack surface and harden your cluster against network threats. You can use built-in security features for risk analysis and security protection. These features help you to protect your cluster infrastructure and network communication, isolate your compute resources, and ensure security compliance across your infrastructure components and container deployments.
5-
6-
# Network Policies and Kubernetes: Adding network policies
7-
In most cases, the default policies do not need to be changed. Only advanced security scenarios might require changes. If you find that you must make changes, install the Calico CLI and create your own network policies
5+
# Network policies and Kubernetes: Adding network policies
6+
In most cases, the default policies do not need to be changed. Only advanced security scenarios might require changes. If you find that you must make changes, install the Calico CLI and create your own network policies.
87

98
Before you begin:
109

11-
Target the Kubernetes CLI to the cluster. Include the --admin option with the bx cs cluster-config command, which is used to download the certificates and permission files. This download also includes the keys for the Administrator rbac role, which you need to run Calico commands.
10+
Target the Kubernetes CLI to the cluster. Include the --admin option with the bx cs cluster-config command, which is used to download the certificates and permission files. This download also includes the keys for the Administrator RBAC role, which you need to run Calico commands.
1211

1312

1413
`bx cs cluster-config <cluster_name> --admin`
1514

16-
Note: Calico CLI version 1.4.0 is supported.
15+
Note: Calico CLI version 1.6.1 is supported.
1716

1817
To add network policies:
1918

20-
Install the Calico CLI, from here: https://github.com/projectcalico/calicoctl/releases/tag/v1.4.0?cm_mc_uid=63538519175715059979315&cm_mc_sid_50200000=1506013543
19+
Install the Calico CLI, from here: https://github.com/projectcalico/calicoctl/releases/tag/v1.6.1
2120

2221
Tip: If you are using Windows, install the Calico CLI in the same directory as the IBM Cloud CLI. This setup saves you some filepath changes when you run commands later.
2322

@@ -33,13 +32,13 @@ OSX:
3332
`mv /<path_to_file>/calico-darwin-amd64 /usr/local/bin/calicoctl`
3433

3534

36-
Next, Convert the binary file to an executable.
35+
Next, convert the binary file to an executable.
3736

3837

3938
`chmod +x /usr/local/bin/calicoctl`
4039

4140

42-
Verify that the calico commands ran properly by checking the Calico CLI client version. Use `calicoctl version`
41+
Verify that the Calico commands run properly by checking the Calico CLI client version. Use `calicoctl version`
4342

4443

4544
# Configure the Calico CLI.
@@ -48,6 +47,7 @@ For Linux and OS X, create the '/etc/calico' directory. For Windows, any directo
4847

4948

5049
`mkdir -p /etc/calico/`
50+
5151
Create a 'calicoctl.cfg' file.
5252

5353
Linux and OS X:
@@ -89,13 +89,16 @@ Linux and OS X:
8989

9090

9191
`dirname $KUBECONFIG`
92+
9293
Output example:
9394

9495
`/home/sysadmin/.bluemix/plugins/container-service/clusters/<cluster_name>-admin/`
96+
9597
Windows:
9698

9799

98100
`echo %KUBECONFIG%`
101+
99102
Output example:
100103

101104
`C:/Users/<user>/.bluemix/plugins/container-service/<cluster_name>-admin/kube-config-prod-<location>-<cluster_name>.yml`
@@ -113,7 +116,9 @@ Windows:
113116
Open the directory you retrieved in the last step.
114117

115118
`C:\Users\.bluemix\plugins\container-service\<cluster_name>-admin\`
119+
116120
Locate the `ca-*pem_file` file.
121+
117122
Verify that the Calico configuration is working correctly.
118123

119124
Linux and OS X:
@@ -136,55 +141,56 @@ Examine the existing network policies.
136141

137142
View the Calico host endpoint.
138143

139-
140144
`calicoctl get hostendpoint -o yaml`
141-
View all of the Calico and Kubernetes network policies that were created for the cluster. This list includes policies that might not be applied to any pods or hosts yet. For a network policy to be enforced, it must find a Kubernetes resource that matches the selector that was defined in the Calico network policy.
142145

146+
View all of the Calico and Kubernetes network policies that were created for the cluster. This list includes policies that might not be applied to any pods or hosts yet. For a network policy to be enforced, it must find a Kubernetes resource that matches the selector that was defined in the Calico network policy.
143147

144148
`calicoctl get policy -o wide`
145-
View details for a network policy.
146149

150+
View details for a network policy.
147151

148152
`calicoctl get policy -o yaml <policy_name>`
149-
View the details of all network policies for the cluster.
150153

154+
View the details of all network policies for the cluster.
151155

152156
`calicoctl get policy -o yaml`
153-
Create the Calico network policies to allow or block traffic.
154157

155158
# Lab Test: Define a Calico network policy
156159

157-
Defining a calico network policy for kubernetes clusters is simple once the calico cli is installed.
160+
Defining a Calico network policy for Kubernetes clusters is simple once the Calico CLI is installed.
158161
This part of the lab walks through using the Calico APIs directly in conjunction with Kubernetes `NetworkPolicy` in order to define more complex network policies.
159162

160-
Begin by creating a network policy object:
163+
Begin by creating a namespace in your Kubernetes cluster:
161164

162165
`kubectl create ns advanced-policy-demo`
163-
And then enable isolation on the Namespace.
166+
167+
And then enable isolation on the namespace.
164168

165169
`kubectl annotate ns advanced-policy-demo "net.beta.kubernetes.io/network-policy={\"ingress\":{\"isolation\":\"DefaultDeny\"}}"`
166-
Run an nginx Service
167170

168-
We’ll run an nginx Service in the Namespace.
169-
```
170-
kubectl run --namespace=advanced-policy-demo nginx --replicas=2 --image=nginx
171-
kubectl expose --namespace=advanced-policy-demo deployment nginx --port=80
172-
```
173-
Check using calicoctl
171+
Now, run an nginx service in the namespace that you created.
172+
173+
`kubectl run --namespace=advanced-policy-demo nginx --replicas=2 --image=nginx`
174+
`kubectl expose --namespace=advanced-policy-demo deployment nginx --port=80`
175+
176+
Now that we’ve created a namespace and a set of pods, we should see those objects show up in the Calico API using calicoctl.
177+
178+
We can see that the namespace has a corresponding network profile.
174179

175-
Now that we’ve created a Namespace and a set of pods, we should see those objects show up in the Calico API using calicoctl.
180+
`calicoctl get profile -o wide`
176181

177-
We can see that the Namespace has a corresponding Profile.
178182
```
179-
$ calicoctl get profile -o wide
180183
NAME TAGS
181184
k8s_ns.advanced-policy-demo k8s_ns.advanced-policy-demo
182185
k8s_ns.default k8s_ns.default
183186
k8s_ns.kube-system k8s_ns.kube-system
184187
```
185-
Because we’ve enabled isolation on the Namespace, the profile denies all ingress traffic and allows all egress traffic.
188+
189+
Because we’ve enabled isolation on the namespace, the profile denies all ingress traffic and allows all egress traffic. Inspect the YAML file to verify.
190+
191+
`calicoctl get profile k8s_ns.advanced-policy-demo -o yaml`
192+
186193
```
187-
$ calicoctl get profile k8s_ns.advanced-policy-demo -o yaml
188194
- apiVersion: v1
189195
kind: profile
190196
metadata:
@@ -201,18 +207,19 @@ $ calicoctl get profile k8s_ns.advanced-policy-demo -o yaml
201207
destination: {}
202208
source: {}
203209
```
204-
We can see that this is the case by running another pod in the Namespace and attempting to access the nginx Service.
210+
We can see that this is the case by running another pod in the namespace and attempting to access the nginx service.
211+
205212
```
206213
$ kubectl run --namespace=advanced-policy-demo access --rm -ti --image busybox /bin/sh
207214
Waiting for pod advanced-policy-demo/access-472357175-y0m47 to be running, status is Pending, pod ready: false
208-
```
209215
If you don't see a command prompt, try pressing enter.
210-
```
211216
/ # wget -q --timeout=5 nginx -O -
212217
wget: download timed out
213218
/ #
214219
```
220+
215221
We can also see that the two nginx pods are represented as WorkloadEndpoints in the Calico API.
222+
216223
```
217224
calicoctl get workloadendpoint
218225
@@ -221,7 +228,9 @@ k8s-node-01 k8s advanced-policy-demo.nginx-701339712-x1uqe eth0
221228
k8s-node-02 k8s advanced-policy-demo.nginx-701339712-xeeay eth0
222229
k8s-node-01 k8s kube-system.kube-dns-v19-mjd8x eth0
223230
```
224-
Taking a closer look, we can see that they reference the correct profile for the Namespace, and that the correct label information has been filled in. Notice that the endpoint also includes a special label calico/k8s_ns, which is automatically populated with the pod’s Kubernetes Namespace.
231+
232+
Taking a closer look, we can see that they reference the correct profile for the namespace, and that the correct label information has been filled in. Notice that the endpoint also includes a special label calico/k8s_ns, which is automatically populated with the pod’s Kubernetes namespace.
233+
225234
```
226235
$ calicoctl get wep --workload advanced-policy-demo.nginx-701339712-x1uqe -o yaml
227236
- apiVersion: v1
@@ -244,7 +253,8 @@ $ calicoctl get wep --workload advanced-policy-demo.nginx-701339712-x1uqe -o yam
244253
- k8s_ns.advanced-policy-demo
245254
246255
```
247-
Now, Simply create a new kubernetes config yaml file, this time with `kind: NetworkPolicy`. The sample below shows an example network policy which allows traffic.
256+
257+
Now, create a new Kubernetes config yaml file, this time with `kind: NetworkPolicy`. The sample below shows an example network policy which allows traffic.
248258

249259
Create a file named `networkpol.yaml`, and enter the following information into the file:
250260

@@ -270,7 +280,7 @@ Linux and OS X:
270280

271281
`calicoctl apply -f networkpol.yaml`
272282

273-
It now shows up as a Policy object in the Calico API.
283+
It now shows up as a policy object in the Calico API.
274284

275285
```
276286
$ calicoctl get policy -o wide

0 commit comments

Comments
 (0)