Skip to content

Commit

Permalink
Merge pull request #46 from DevNetSandbox/ccp5.1
Browse files Browse the repository at this point in the history
CCP 5.1 Swagger
  • Loading branch information
klevenstein committed Aug 7, 2020
2 parents 59f5e25 + 7e1122b commit 5972e70
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 40 deletions.
5 changes: 4 additions & 1 deletion labs/CiscoContainerPlatform-101/1.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ First, we'll need a Cisco Container Platform environment, luckily we have plenty
### Reserve a Cisco Container Platform sandbox
For this we will use the "Cisco Container Platform DEVNET Sandbox", this environment will provide access to a pre-installed Cisco Container Platform cluster, serving as our "on premise" setup for this Lab.

Go to [https://devnetsandbox.cisco.com](https://devnetsandbox.cisco.com/RM/Diagram/Index/2a998773-f251-4b69-b02d-2b1c115ecc50?diagramType=Topology), login and reserve the "Cisco Container Platform v3.1" sandbox for 2 hours.
Go to [https://devnetsandbox.cisco.com](https://devnetsandbox.cisco.com/RM/Diagram/Index/2a998773-f251-4b69-b02d-2b1c115ecc50?diagramType=Topology), login and reserve the "Cisco Container Platform" sandbox for 2 hours.

![](assets/images/sandbox-ccp.jpeg)

Expand Down Expand Up @@ -97,6 +97,9 @@ Logging in presents you with the "Clusters" screen. Here we can see all the Kube

![](assets/images/ccp-clusters.jpeg)

> *Note*: CCP supports single-master node (v2) and multi-master nodes (v3) deployments. Please choose v2 for the following steps.
![](assets/images/ccp_versions_chosen.png)

## B. View your available Clusters

In a new Lab environment, you will have a single cluster pre-created `Sandbox-Demo-Cluster-1`. You can click on this cluster to see details of the nodes, IP addresses and links to access the dashboard and download the `kubeconfig` file for authentication.
Expand Down
31 changes: 31 additions & 0 deletions labs/CiscoContainerPlatform-101/2.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,37 @@ Notice in the Cluster details page, a VIP has already been assigned to the Maste
Each Cisco Container platform installation comes with integrated Open API documentation, powered by OpenAPI (Swagger tooling).
You can access this [HERE (https://10.10.20.110/2/swaggerapi/)](https://10.10.20.110/2/swaggerapi/), where you see all the currently supported platform APIs.

> *Note*: Under some circumstances, the Swagger API page may fail to load. This is a known issue. If you are using the Chrome browser, use the following workaround procedure::

1. Open the Swagger API page using the following URL:```https://<ccp_ui_ip>/2/swaggerapi```

2. Click the **...** icon at the upper right corner of the menu bar, and then choose **More Tools > Developer Tools**.

The Developer Tools panel appears.

3. Click **Sources > Overrides > Select folder for overrides**.

4. Select a newly created empty folder to store the local overrides.

5. In the notification that appears just below the URL bar, click **Allow** to give Developer Tools full access to the selected folder.

6. Check the **Enable Local Overrides** checkbox.

7. Click the **Page** tab and click on the index file.

The index file appears in the right pane.
![](assets/images/swagger_not_loading.png)
8. Edit the index file to add the following line after the first line:
```
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
```

9. Save the file and ensure that the Swagger page loads correctly.

10. Close the Developer Tools panel.


Click on `List Operations` to see titles, then `Expand Operations` to expand the subsections ready to use the APIs in the next section; in this Lab, we're going to use the `/2/system` and `/2/clusters` sections, so expand those:

![](assets/images/expand_swagger_1.jpeg)
Expand Down
118 changes: 81 additions & 37 deletions labs/CiscoContainerPlatform-101/3.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,61 @@ Scroll down to the green `POST` request, which allows us to create a new cluster
Use the following text in the BODY field, notice that these are all the same options (potentially in UUID form) which we specified from the UI.

```
{"is_harbor_enabled":false,"provider_client_config_uuid":"f610d6d4-5cd7-4a3c-937a-dbf69280dc5b","name":"API-Cluster","kubernetes_version":"1.12.3","ssh_key":"ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBAHlSb9ZkXQL5/GI12258c+AIKVhDN1p1VYjvJR5oliqoR/gN/65D04BfsZWE8nk00AtJzvEVbjenwLeWuvIQsFs5AHa5uM4Fpmw3Ylpt1tB/GZHZ5Mg9sh1iLh5agSgNLWkAgCRvySmLO3fSq0IKarnQrMqId2pGUlNZr/YPP4irTvU6w== sandbox@CCP_SANDBOX_NISTP521_KEY","description":"Cluster created via API","datacenter":"CCP","cluster":"CCP","resource_pool":"CCP/Resources","networks":["VMNetwork"],"datastore":"CCPDatastore","storage_class":"vsphere","workers":1,"ssh_user":"ccpuser","type":1,"masters":1,"deployer_type":"kubeadm","ingress_vip_pool_id":"15ee6d0f-2709-4a7f-871e-71ce5c8568be","load_balancer_ip_num":4,"is_istio_enabled":false,"registries_root_ca":[""],"aws_iam_enabled":false,"aws_iam_role_arn":"","worker_node_pool":{"vcpus":2,"memory":16384,"template":"ccp-tenant-image-1.12.3-ubuntu18-3.1.0"},"master_node_pool":{"vcpus":2,"memory":16384,"template":"ccp-tenant-image-1.12.3-ubuntu18-3.1.0"},"node_ip_pool_uuid":"15ee6d0f-2709-4a7f-871e-71ce5c8568be","network_plugin":{"name":"calico","status":"","details":"{\"pod_cidr\":\"192.168.0.0/16\"}"},"deployer":{"proxy_cmd":"StrictHostKeyChecking no\nHost 15.29.3?.* !15.29.30.* !15.29.31.*\n ProxyCommand nc --proxy 10.193.231.10:8111 --proxy-type socks4 %h %p","provider_type":"vsphere","provider":{"vsphere_datacenter":"CCP","vsphere_datastore":"CCPDatastore","vsphere_client_config_uuid":"f610d6d4-5cd7-4a3c-937a-dbf69280dc5b","vsphere_working_dir":"/CCP/vm"}}}
{
"is_harbor_enabled":false,
"provider_client_config_uuid":"5215ae97-c11a-435c-80fa-06adef135f45",
"name":"api-cluster",
"kubernetes_version":"1.14.8",
"ssh_key":"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINksnIyqCWNUdHoXx3G8PVg8Z9tWnSGGI/r2F/REwh3a gitlab",
"description":"Cluster created via API",
"datacenter":"CCP",
"cluster":"CCP",
"resource_pool":"CCP/Resources",
"networks":[
"VMNetwork"
],
"datastore":"CCPDatastore",
"storage_class":"vsphere",
"workers":1,
"ssh_user":"ccpuser",
"type":1,
"masters":1,
"deployer_type":"kubeadm",
"ingress_vip_pool_id":"55c267fd-d8cd-4c52-b288-4ad2697fe57a",
"load_balancer_ip_num":4,
"is_istio_enabled":false,
"registries_root_ca":[
""
],
"aws_iam_enabled":false,
"aws_iam_role_arn":"",
"worker_node_pool":{
"vcpus":2,
"memory":16384,
"template":"ccp-tenant-image-1.14.8-ubuntu18-5.1.0"
},
"master_node_pool":{
"vcpus":2,
"memory":16384,
"template":"ccp-tenant-image-1.14.8-ubuntu18-5.1.0"
},
"node_ip_pool_id":"55c267fd-d8cd-4c52-b288-4ad2697fe57a",
"network_plugin":{
"name":"calico",
"status":"",
"details":"{\"pod_cidr\":\"192.168.0.0/16\"}"
},
"deployer":{
"proxy_cmd":"StrictHostKeyChecking no\nHost 15.29.3?.* !15.29.30.* !15.29.31.*\n ProxyCommand nc --proxy 10.193.231.10:8111 --proxy-type socks4 %h %p",
"provider_type":"vsphere",
"provider":{
"vsphere_datacenter":"CCP",
"vsphere_datastore":"CCPDatastore",
"vsphere_client_config_uuid":"5215ae97-c11a-435c-80fa-06adef135f45",
"vsphere_working_dir":"/CCP/vm"
}
}
}
```
It will create us a one worker node cluster called "API-Cluster".

Expand Down Expand Up @@ -83,7 +137,7 @@ data:
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
metadata:
name: owncloud-config-claim
labels:
app: owncloud
Expand All @@ -97,7 +151,7 @@ spec:
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
metadata:
name: owncloud-data-claim
labels:
app: owncloud
Expand All @@ -111,7 +165,7 @@ spec:
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
metadata:
name: owncloud-apps-claim
labels:
app: owncloud
Expand Down Expand Up @@ -150,7 +204,7 @@ data:
owc_admin_user: demo
# NB: This is the ip address, or name, of a domain that ownCloud will allow
# users to log in to the web interface from. Once the application is
# running additional domains can be added either via the web interface or
# running additional domains can be added either via the web interface or
# 'php occ' tool
owc_trusted_ip: 10.10.20.121
---
Expand All @@ -159,9 +213,9 @@ kind: Deployment
metadata:
name: owncloud-dockerhub
labels:
app: owncloud
app: owncloud
spec:
replicas: 1
replicas: 1
template:
metadata:
# unlike a "name" is not included, instead it is automatically
Expand Down Expand Up @@ -192,14 +246,15 @@ spec:
valueFrom:
secretKeyRef:
name: owncloud
key: mariadb_root_password
key: mariadb_root_password
image: mariadb:10.1
imagePullPolicy: IfNotPresent
ports:
- containerPort: 3306
volumeMounts:
- name: mdata-store
mountPath: /var/lib/mysql
- name: owncloud
env:
- name: MYSQL_ROOT_PASSWORD
Expand Down Expand Up @@ -237,8 +292,9 @@ spec:
configMapKeyRef:
name: owncloud-configmap
key: owc_trusted_ip
image: owncloud:9.1
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
Expand All @@ -256,67 +312,55 @@ spec:
- |
# Enable bash debug tracing and blow up if any command fails
set -ex
# In order to get this running successfully in k8's what we'll do is essentially
# copy the normal Docker startup process. Which is essentially to untar owncloud
# into a apache install and then fire up apache. But instead of the untar and then
# immediately firing up apache, we'll inject the necessary setup to get things
# copy the normal Docker startup process. Which is essentially to untar owncloud
# into a apache install and then fire up apache. But instead of the untar and then
# immediately firing up apache, we'll inject the necessary setup to get things
# playing nicely in k8's.
# Extracted from the OwnCloud Docker image with a docker inspect owncloud:9.1
# Extracted from the Owncloud Docker image with a docker inspect owncloud:9.1
OWC_DOCKER_WORKING_DIR=/var/www/html
OWC_DOCKER_ENTRYPOINT=/entrypoint.sh
OWC_DOCKER_CMD=apache2-foreground
# Some of the files need to have specific perms and some of the commands
# are best executed as the www user in order that things work nicely
OWC_DOCKER_USER=www-data
OWC_DOCKER_GROUP=nogroup
# No sudo installed, so need to emulate
SU_CMD_STEM="su --login www-data --shell /bin/sh --command "
# Perform default OwnCloud Docker intialisation because we've overridden it
# Perform default Owncloud Docker intialisation because we've overridden it
# and we need it in in place before we can do a command line installation.
# (this does untar etc on the owncloud install)
cd $OWC_DOCKER_WORKING_DIR
$OWC_DOCKER_ENTRYPOINT
# Check we have got what looks like a working owncloud install after running the entrypoint
$SU_CMD_STEM "which php"
ls occ
# Now we tailor the installation to run under kubernetes. Some of this we only want to
# do once, as the OwnCloud will tailor the settings itself and we do not want to
# stamp on those. Others we need to do every time because they are specific to the
# Now we tailor the installation to run under kubernetes. Some of this we only want to
# do once, as the Owncloud will tailor the settings itself and we do not want to
# stamp on those. Others we need to do every time because they are specific to the
# pod instance.
RUN_BEFORE_FLAG_FILE=config/k8initialised.touch
num_trusted_domains=0
if [[ -f $RUN_BEFORE_FLAG_FILE ]]; then
# Then the disk has already been set up.
echo INFO OwnCloud initialised on this volume, not running config setup again.
echo INFO Owncloud initialised on this volume, not running config setup again.
else
echo INFO Initialising OwnCloud on this volume.
echo INFO Initialising Owncloud on this volume.
# Fix broken ownership from the install on data (comes out as root otherwise)
chown --recursive $OWC_DOCKER_USER:$OWC_DOCKER_GROUP data
# Invoke OwnCloud's command line installation tools to add DB, trusted_domain etc.
chown --recursive $OWC_DOCKER_USER:$OWC_DOCKER_GROUP data
# Invoke Owncloud's command line installation tools to add DB, trusted_domain etc.
$SU_CMD_STEM "cd $OWC_DOCKER_WORKING_DIR && php occ maintenance:install --database $OWC_DB_TYPE --database-host 127.0.0.1 --database-name $OWC_DB_NAME --database-user $OWC_DB_ROOT_USER --database-pass $MYSQL_ROOT_PASSWORD --admin-user $OWC_ADMIN_USER --admin-pass $OWC_ADMIN_PASSWORD"
# Add a file so that we do not run the same set up again and stamp
# on the existing setup
touch $RUN_BEFORE_FLAG_FILE
fi
# Add trusted_domains so that can access with OwnCloud
# Add trusted_domains so that can access with Owncloud
$SU_CMD_STEM "cd $OWC_DOCKER_WORKING_DIR && php occ config:system:set trusted_domains $num_trusted_domains --value=$(OWC_TRUSTED_IP)"
num_trusted_domains=`expr $num_trusted_domains + 1`
#Fire off the normal Docker startup
$OWC_DOCKER_CMD
```


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"labId": "CiscoContainerPlatform-101",
"title": "A hands-on introduction to the Cisco Container Platform v3.1",
"slug": "UPDATED to CCP v3.1! Automatically provision and use Kubernetes clusters with Cisco Container Platform.",
"title": "A hands-on introduction to the Cisco Container Platform",
"slug": "UPDATED to CCP v5.1! Automatically provision and use Kubernetes clusters with Cisco Container Platform.",
"time": "30",
"tags": [{
"title": "Kubernetes"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5972e70

Please sign in to comment.