Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ibm-cloud/get-started-python
A Python application and tutorial that use Flask framework to provide a REST API to receive requests from the UI. The API then persists the data to a Cloudant database.
https://github.com/ibm-cloud/get-started-python
bluemix database flask python sample tutorial
Last synced: 4 days ago
JSON representation
A Python application and tutorial that use Flask framework to provide a REST API to receive requests from the UI. The API then persists the data to a Cloudant database.
- Host: GitHub
- URL: https://github.com/ibm-cloud/get-started-python
- Owner: IBM-Cloud
- License: apache-2.0
- Created: 2015-03-19T21:04:43.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2024-08-13T18:22:31.000Z (5 months ago)
- Last Synced: 2024-12-29T06:02:32.460Z (11 days ago)
- Topics: bluemix, database, flask, python, sample, tutorial
- Language: JavaScript
- Homepage: https://console.ng.bluemix.net/docs/runtimes/python/getting-started.html
- Size: 55.7 KB
- Stars: 121
- Watchers: 34
- Forks: 444
- Open Issues: 10
-
Metadata Files:
- Readme: README-kubernetes.md
- License: LICENSE
Awesome Lists containing this project
README
# Deploy to IBM Cloud Kubernetes Service
Follow these instructions to deploy this application to a Kubernetes cluster and connect it with a Cloudant database.
## Download
```bash
https://github.com/IBM-Cloud/get-started-python
cd get-started-python
```## Build Docker Image
1. Find your container registry **namespace** by running `ibmcloud cr namespaces`. If you don't have any, create one using `ibmcloud cr namespace-add `
2. Identify your **Container Registry** by running `ibmcloud cr info` (Ex: registry.ng.bluemix.net)
3. Build and tag (`-t`)the docker image by running the command below replacing REGISTRY and NAMESPACE with he appropriate values.
```sh
docker build . -t //myapp:v1.0.0
```
Example: `docker build . -t registry.ng.bluemix.net/mynamespace/myapp:v1.0.04. Push the docker image to your Container Registry on IBM Cloud
```sh
docker push //myapp:v1.0.0
```## Deploy
#### Create a Kubernetes cluster
1. [Creating a Kubernetes cluster in IBM Cloud](https://console.bluemix.net/docs/containers/container_index.html#clusters).
2. Follow the instructions in the Access tab to set up your `kubectl` cli.#### Create a Cloudant Database
1. Go to the [Catalog](https://console.bluemix.net/catalog/) and create a new [Cloudant](https://console.bluemix.net/catalog/services/cloudant-nosql-db) database instance.
2. Choose `Legacy and IAM` for **Authentication**
3. Create new credentials under **Service Credentials** and copy value of the **url** field.
4. Create a Kubernetes secret with your Cloudant credentials (url, username and password).
```bash
kubectl create secret generic cloudant --from-literal=url= --from-literal=username= --from-literal=password=
```
Example:
```bash
kubectl create secret generic cloudant --from-literal=url=https://myusername:[email protected] --from-literal=username=myusername --from-literal=password=passw0rd
```#### Create the deployment
1. Replace `` and `` with the appropriate values in `kubernetes/deployment.yaml`
2. Create a deployment:
```shell
kubectl create -f kubernetes/deployment.yaml
```
- **Paid Cluster**: Expose the service using an External IP and Loadbalancer
```
kubectl expose deployment get-started-python --type LoadBalancer --port 8000 --target-port 8000
```- **Free Cluster**: Use the Worker IP and NodePort
```bash
kubectl expose deployment get-started-python --type NodePort --port 8000 --target-port 8000
```### Access the application
Verify **STATUS** of pod is `RUNNING`
```shell
kubectl get pods -l app=get-started-python
```**Standard (Paid) Cluster:**
1. Identify your LoadBalancer Ingress IP using `kubectl get service get-started-python`
2. Access your application at t `http://:8000/`**Free Cluster:**
1. Identify your Worker Public IP using `ibmcloud cs workers YOUR_CLUSTER_NAME`
2. Identify the Node Port using `kubectl describe service get-started-python`
3. Access your application at `http://:/`## Clean Up
```bash
kubectl delete deployment,service -l app=get-started-python
kubectl delete secret cloudant
```