Initial commit

This commit is contained in:
Tomas Pizarro
2017-11-13 16:29:00 +00:00
commit f9cd46c375
22 changed files with 846 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
<!--
If you are reporting a new issue, make sure that we do not have any duplicates
already open. You can ensure this by searching the issue list for this
repository. If there is a duplicate, please close your issue and add a comment
to the existing issue instead.
If you suspect your issue is a bug, please edit your issue description to
include the BUG REPORT INFORMATION shown below. If you fail to provide this
information within 7 days, we cannot debug your issue and we'll close it. We
will, however, reopen it if you later provide the information.
-------------------------------
BUG REPORT INFORMATION
-------------------------------
Use the commands below to provide key information from your environment:
You do NOT have to include this information if this is a FEATURE REQUEST
-->
**Description**
<!-- Briefly describe the problem you are having in a few paragraphs. -->
**Steps to reproduce the issue:**
1. [First Step]
2. [Second Step]
3. [and so on...]
**Describe the results you received:**
<!-- What actually happens -->
**Describe the results you expected:**
<!-- What you expect to happen -->
**Additional information you deem important (e.g. issue happens only occasionally):**
<!-- Any additional information, configuration or data that might be necessary to reproduce the issue. -->
**Version**
- Output of `docker version`:
```
(paste your output here)
```
- Output of `docker info`:
```
(paste your output here)
```
- Output of `docker-compose version` (if applicable):
```
(paste your output here)
```
**Additional environment details (AWS, VirtualBox, Docker for MAC, physical, etc.):**

View File

@@ -0,0 +1,32 @@
<!--
Before you open the request please review the following guidelines and tips to help it be more easily integrated:
- Describe the scope of your change - i.e. what the change does.
- Describe any known limitations with your change.
- Please run any tests or examples that can exercise your modified code.
Thank you for contributing! We will try to test and integrate the change as soon as we can, but be aware we have many GitHub repositories to manage and can't immediately respond to every request. There is no need to bump or check in on a pull request (it will clutter the discussion of the request).
Also don't be worried if the request is closed or not integrated sometimes the priorities of Bitnami might not match the priorities of the pull request. Don't fret, the open source community thrives on forks and GitHub makes it easy to keep your changes in a forked repo.
-->
**Description of the change**
<!-- Describe the scope of your change - i.e. what the change does. -->
**Benefits**
<!-- What benefits will be realized by the code change? -->
**Possible drawbacks**
<!-- Describe any known limitations with your change -->
**Applicable issues**
<!-- Enter any applicable Issues here (You can reference an issue using #) -->
**Additional information**
<!-- If there's anything else that's important and relevant to your pull
request, mention that information here.-->

1
bitnami/python/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
local/

View File

@@ -0,0 +1,18 @@
FROM bitnami/minideb-runtimes:jessie
LABEL maintainer "Bitnami <containers@bitnami.com>"
# Install required system packages and dependencies
RUN install_packages build-essential ca-certificates curl git libbz2-1.0 libc6 libncurses5 libreadline6 libsqlite3-0 libssl1.0.0 libtinfo5 pkg-config unzip wget zlib1g
RUN wget -nc -P /tmp/bitnami/pkg/cache/ https://downloads.bitnami.com/files/stacksmith/python-2.7.14-0-linux-x64-debian-8.tar.gz && \
echo "2ad513d9d4d4e2c2f98d96448617b5ab3c5dd48dc2e3cb02080ecc7215039ffa /tmp/bitnami/pkg/cache/python-2.7.14-0-linux-x64-debian-8.tar.gz" | sha256sum -c - && \
tar -zxf /tmp/bitnami/pkg/cache/python-2.7.14-0-linux-x64-debian-8.tar.gz -P --transform 's|^[^/]*/files|/opt/bitnami|' --wildcards '*/files' && \
rm -rf /tmp/bitnami/pkg/cache/python-2.7.14-0-linux-x64-debian-8.tar.gz
ENV BITNAMI_APP_NAME="python" \
BITNAMI_IMAGE_VERSION="2.7.14-r0" \
PATH="/opt/bitnami/python/bin:$PATH"
EXPOSE 8000
WORKDIR /app
CMD ["python"]

View File

@@ -0,0 +1,12 @@
version: '2'
services:
python:
tty: true # Enables debugging capabilities when attached to this container.
image: 'bitnami/python:2'
labels:
kompose.service.type: nodeport
ports:
- 8000:8000
volumes:
- .:/app

View File

@@ -0,0 +1,13 @@
FROM bitnami/python:2 as development
FROM bitnami/minideb-runtimes:jessie
LABEL maintainer "Bitnami <containers@bitnami.com>"
COPY --from=development /opt/bitnami/python /opt/bitnami/python
ENV BITNAMI_APP_NAME="python" \
BITNAMI_IMAGE_VERSION="2.7.14-r0" \
PATH="/opt/bitnami/python/bin:$PATH"
CMD ["python"]

View File

@@ -0,0 +1,18 @@
FROM bitnami/minideb-runtimes:jessie
LABEL maintainer "Bitnami <containers@bitnami.com>"
# Install required system packages and dependencies
RUN install_packages build-essential ca-certificates curl git libbz2-1.0 libc6 libncurses5 libreadline6 libsqlite3-0 libssl1.0.0 libtinfo5 pkg-config unzip wget zlib1g
RUN wget -nc -P /tmp/bitnami/pkg/cache/ https://downloads.bitnami.com/files/stacksmith/python-3.6.3-0-linux-x64-debian-8.tar.gz && \
echo "efbf832408cf62b6a2fb4c44010252cfe374528f22bc2a7d2b6240512a77322b /tmp/bitnami/pkg/cache/python-3.6.3-0-linux-x64-debian-8.tar.gz" | sha256sum -c - && \
tar -zxf /tmp/bitnami/pkg/cache/python-3.6.3-0-linux-x64-debian-8.tar.gz -P --transform 's|^[^/]*/files|/opt/bitnami|' --wildcards '*/files' && \
rm -rf /tmp/bitnami/pkg/cache/python-3.6.3-0-linux-x64-debian-8.tar.gz
ENV BITNAMI_APP_NAME="python" \
BITNAMI_IMAGE_VERSION="3.6.3-r0" \
PATH="/opt/bitnami/python/bin:$PATH"
EXPOSE 8000
WORKDIR /app
CMD ["python"]

View File

@@ -0,0 +1,12 @@
version: '2'
services:
python:
tty: true # Enables debugging capabilities when attached to this container.
image: 'bitnami/python:3'
labels:
kompose.service.type: nodeport
ports:
- 8000:8000
volumes:
- .:/app

View File

@@ -0,0 +1,13 @@
FROM bitnami/python:3 as development
FROM bitnami/minideb-runtimes:jessie
LABEL maintainer "Bitnami <containers@bitnami.com>"
COPY --from=development /opt/bitnami/python /opt/bitnami/python
ENV BITNAMI_APP_NAME="python" \
BITNAMI_IMAGE_VERSION="3.6.3-r0" \
PATH="/opt/bitnami/python/bin:$PATH"
CMD ["python"]

13
bitnami/python/LICENSE Normal file
View File

@@ -0,0 +1,13 @@
Copyright (c) 2017 Bitnami
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

150
bitnami/python/README.md Normal file
View File

@@ -0,0 +1,150 @@
[![CircleCI](https://circleci.com/gh/bitnami/bitnami-docker-python/tree/master.svg?style=shield)](https://circleci.com/gh/bitnami/bitnami-docker-python/tree/master)
[![Slack](https://img.shields.io/badge/slack-join%20chat%20%E2%86%92-e01563.svg)](http://slack.oss.bitnami.com)
# What is Python?
> Python is a programming language that lets you work quickly and integrate systems more effectively
[python.org](https://www.python.org/)
# TL;DR;
```bash
$ docker run -it --name python bitnami/python
```
## Docker Compose
```bash
$ curl -sSL https://raw.githubusercontent.com/bitnami/bitnami-docker-mariadb/master/docker-compose.yml > docker-compose.yml
$ docker-compose up -d
```
# Why use Bitnami Images?
* Bitnami closely tracks upstream source changes and promptly publishes new versions of this image using our automated systems.
* With Bitnami images the latest bug fixes and features are available as soon as possible.
* Bitnami containers, virtual machines and cloud images use the same components and configuration approach - making it easy to switch between formats based on your project needs.
* Bitnami images are built on CircleCI and automatically pushed to the Docker Hub.
* All our images are based on [minideb](https://github.com/bitnami/minideb) a minimalist Debian based container image which gives you a small base container image and the familiarity of a leading linux distribution.
# Supported tags and respective `Dockerfile` links
- [`3`, `3.6.3-r0`, `latest` (3/Dockerfile)](https://github.com/bitnami/bitnami-docker-python/blob/3.6.3-r0/3/Dockerfile), [`3-prod`, `3.6.3-r0-prod` (3/prod/Dockerfile)](https://github.com/bitnami/bitnami-docker-python/blob/3.6.3-r0/3/prod/Dockerfile)
- [`2`, `2.7.14-r0` (2/Dockerfile)](https://github.com/bitnami/bitnami-docker-python/blob/2.7.14-r0/2/Dockerfile), [`2-prod`, `2.7.14-r0-prod` (2/prod/Dockerfile)](https://github.com/bitnami/bitnami-docker-python/blob/2.7.14-r0/2/prod/Dockerfile)
Subscribe to project updates by watching the [bitnami/python GitHub repo](https://github.com/bitnami/bitnami-docker-python).
# Get this image
The recommended way to get the Bitnami Python Docker Image is to pull the prebuilt image from the [Docker Hub Registry](https://hub.docker.com/r/bitnami/python).
```bash
$ docker pull bitnami/python:latest
```
To use a specific version, you can pull a versioned tag. You can view the [list of available versions](https://hub.docker.com/r/bitnami/python/tags/) in the Docker Hub Registry.
```bash
$ docker pull bitnami/python:[TAG]
```
If you wish, you can also build the image yourself.
```bash
$ docker build -t bitnami/python https://github.com/bitnami/bitnami-docker-python.git
```
# Entering the REPL
By default, running this image will drop you into the Python REPL, where you can interactively test and try things out in Python.
```bash
$ docker run -it --name python bitnami/python
```
# Running your Python script
The default work directory for the Python image is `/app`. You can mount a folder from your host here that includes your Python script, and run it normally using the `python` command.
```bash
$ docker run -it --name python -v /path/to/app:/app bitnami/python \
python script.py
```
# Maintenance
## Upgrade this image
Bitnami provides up-to-date versions of Python, including security patches, soon after they are made upstream. We recommend that you follow these steps to upgrade your container.
### Step 1: Get the updated image
```bash
$ docker pull bitnami/python:latest
```
or if you're using Docker Compose, update the value of the image property to `bitnami/python:latest`.
### Step 2: Remove the currently running container
```bash
$ docker rm -v python
```
or using Docker Compose:
```bash
$ docker-compose rm -v python
```
### Step 3: Run the new image
Re-create your container from the new image.
```bash
$ docker run --name python bitnami/python:latest
```
or using Docker Compose:
```bash
$ docker-compose start python
```
# Contributing
We'd love for you to contribute to this Docker image. You can request new features by creating an [issue](https://github.com/bitnami/bitnami-docker-python/issues), or submit a [pull request](https://github.com/bitnami/bitnami-docker-python/pulls) with your contribution.
# Issues
If you encountered a problem running this container, you can file an [issue](https://github.com/bitnami/bitnami-docker-python/issues). For us to provide better support, be sure to include the following information in your issue:
- Host OS and version
- Docker version (`docker version`)
- Output of `docker info`
- Version of this container (`echo $BITNAMI_IMAGE_VERSION` inside the container)
- The command you used to run the container, and any relevant output you saw (masking any sensitive
information)
# Community
Most real time communication happens in the `#containers` channel at [bitnami-oss.slack.com](http://bitnami-oss.slack.com); you can sign up at [slack.oss.bitnami.com](http://slack.oss.bitnami.com).
Discussions are archived at [bitnami-oss.slackarchive.io](https://bitnami-oss.slackarchive.io).
# License
Copyright (c) 2017 Bitnami
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

63
bitnami/python/circle.yml Normal file
View File

@@ -0,0 +1,63 @@
version: 2
jobs:
build:
working_directory: /workdir
docker:
- image: docker:17.06.0-ce-git
environment:
RELEASE_SERIES_LIST: "3,2"
LATEST_STABLE: "3"
IMAGE_NAME: python
DOCKER_PROJECT: bitnami
QUAY_PROJECT: bitnami
GCLOUD_PROJECT: bitnami-containers
steps:
- checkout
- setup_remote_docker:
version: 17.06.0-ce
- run:
name: Upgrade system packages (workaround - https://github.com/docker-library/docker/issues/72)
command: |
apk upgrade --no-cache
- run:
name: Install dependencies
command: |
apk add --no-cache curl bash coreutils
- run:
name: Docker info
command: |
docker version
docker info
- restore_cache:
keys:
- cache-{{ .Branch }}
paths:
- /cache/layers.tar
- run:
name: Build docker image
command: |
curl -sL https://raw.githubusercontent.com/bitnami/test-infra/master/circle/docker-image-test.sh | bash -
- save_cache:
key: cache-{{ .Branch }}-{{ epoch }}
paths:
- /cache/layers.tar
- deploy:
name: Publish docker image
command: |
if [ -n "${CIRCLE_TAG}" ]; then
curl -sL https://raw.githubusercontent.com/bitnami/test-infra/master/circle/docker-release-image.sh | bash -
elif [ "${CIRCLE_BRANCH}" == "master" ]; then
curl -sL https://raw.githubusercontent.com/bitnami/test-infra/master/circle/docker-development-image.sh | bash -
fi
workflows:
version: 2
build-and-deploy:
jobs:
- build:
filters:
branches:
only: /.*/
tags:
only: /^[0-9].*-r[0-9]+$/

View File

@@ -0,0 +1,12 @@
version: '2'
services:
python:
tty: true # Enables debugging capabilities when attached to this container.
image: 'bitnami/python:latest'
labels:
kompose.service.type: nodeport
ports:
- 8000:8000
volumes:
- .:/app

View File

@@ -0,0 +1,2 @@
kubernetes.yml
README.md

View File

@@ -0,0 +1,13 @@
FROM bitnami/python:2 as builder
COPY . /app
WORKDIR /app
RUN virtualenv . && \
. bin/activate && \
pip install django && \
python manage.py migrate
FROM bitnami/python:2-prod
COPY --from=builder /app /app
WORKDIR /app
EXPOSE 8000
CMD bash -c "source bin/activate && python manage.py runserver 0:8000"

View File

@@ -0,0 +1,137 @@
# Example Application
## TL;DR
```bash
$ kubectl create -f https://raw.githubusercontent.com/bitnami/bitnami-docker-python/master/example/kubernetes.yml
```
## Introduction
This example demostrates the use of the `bitnami/python` image to create a production build of your python application.
For demonstration purposes we'll bootstrap a [Django](https://www.djangoproject.com/) application, build a image with the tag `bitnami/python-example` and deploy it on a [Kubernetes](https://kubernetes.io) cluster.
## Generate the application
The example application is a [Django](https://www.djangoproject.com/) application bootstrapped using the `django-admin` utility.
```bash
$ django-admin startproject example
```
## Build and Test
To build a production Docker image of our application we'll use the `bitnami/python:2-prod` image, which is a production build of the Bitnami Python Image optimized for size.
```dockerfile
FROM bitnami/python:2 as builder
COPY . /app
WORKDIR /app
RUN virtualenv . && \
. bin/activate && \
pip install django && \
python manage.py migrate
FROM bitnami/python:2-prod
COPY --from=builder /app /app
WORKDIR /app
EXPOSE 8000
CMD bash -c "source bin/activate && python manage.py runserver 0:8000"
```
The `Dockerfile` consists of two build stages. The first stage uses the development image, `bitnami/python:2`, to copy the application source, create a virtualenv and install the required application modules with `pip`.
The second stage uses the production image, `bitnami/python:2-prod`, and copies over the application source and the installed modules from the previous stage. This creates a minimal Docker image that only consists of the application source, python modules and the python runtime.
To build the Docker image, execute the command:
```bash
$ docker build -t bitnami/python-example:0.0.1 example/
```
Since the `bitnami/python:2-prod` image is optimized for production deployments it does not include any packages that would bloat the image.
```console
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
bitnami/python-example 0.0.1 0d43bbca1cd2 22 seconds ago 193MB
```
You can now launch and test the image locally.
```console
$ docker run -it --rm -p 8000:8000 bitnami/python-example:0.0.1
Performing system checks...
System check identified no issues (0 silenced).
November 09, 2017 - 11:25:27
Django version 1.11.7, using settings 'example.settings'
Starting development server at http://0:8000/
Quit the server with CONTROL-C.
```
Finally, push the image to the Docker registry
```bash
$ docker push bitnami/python-example:0.0.1
```
## Deployment
The `kubernetes.yml` file from the `example/` folder can be used to deploy our `bitnami/python-example:0.0.1` image to a Kubernetes cluster.
Simply download the Kubernetes manifest and create the Kubernetes resources described in the manifest using the command:
```console
$ kubectl create -f kubernetes.yml
ingress "example-ingress" created
service "example-svc" created
persistentvolumeclaim "example-data-pvc" created
deployment "example-deployment" created
```
From the output of the above command you will notice that we create the following resources:
- [Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/)
- [Service](https://kubernetes.io/docs/concepts/services-networking/service/)
- [Volume](https://kubernetes.io/docs/concepts/storage/volumes/)
+ [PersistentVolumeClaim](https://kubernetes.io/docs/concepts/storage/volumes/#persistentvolumeclaim)
- [Deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/)
> **Note**
>
> Our example application is stateless and does not store any data or does not require any user configurations. As such we do not need to create the `PersistentVolumeClaim` resource. Our `kubernetes.yml` creates this resource strictly to demostrate how it is defined in the manifest.
## Accessing the application
Typically in production you would access the application via a Ingress controller. Our `kubernetes.yml` already defines a `Ingress` resource. Please refer to the [Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/) documentation to learn how to deploy an ingress controller in your cluster.
> **Hint**
>
> https://kubeapps.com/charts/stable/nginx-ingress
The following are alternate ways of accessing the application, typically used during application development and testing.
Since the service `example-svc` is defined to be of type `NodePort`, we can set up port forwarding to access our web application like so:
```bash
$ kubectl port-forward $(kubectl get pods -l app=example -o jsonpath="{ .items[0].metadata.name }") 8000:8000
```
The command forwards the local port `8000` to port `8000` of the Pod container. You can access the application by visiting the http://localhost:8000.
> **Note:**
>
> If your using minikube, you can access the application by simply executing the following command:
>
> ```bash
> $ minikube service example-svc
> ```
## Health Checks
The `kubernetes.yml` manifest defines default probes to check the health of the application. For our application we are simply probing if the application is responsive to queries on the root resource.
You application can define a route, such as the commonly used `/healthz`, that reports the application status and use that route in the health probes.

View File

@@ -0,0 +1,120 @@
"""
Django settings for example project.
Generated by 'django-admin startproject' using Django 1.11.7.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '@lgvsj4kea_42o(aa6$dza_c2oc_7(7-79dth2gkjrrbxr$p3u'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'example.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'example.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'

View File

@@ -0,0 +1,21 @@
"""example URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
]

View File

@@ -0,0 +1,16 @@
"""
WSGI config for example project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")
application = get_wsgi_application()

View File

@@ -0,0 +1,98 @@
apiVersion: v1
items:
- apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: example-ingress
labels:
app: example
annotations:
spec:
rules:
- host: app.example.com
http:
paths:
- path: /
backend:
serviceName: example-svc
servicePort: 80
tls:
- apiVersion: v1
kind: Service
metadata:
name: example-svc
labels:
app: example
spec:
ports:
- name: http
port: 80
targetPort: http
selector:
app: example
type: NodePort
status:
loadBalancer: {}
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: example-data-pvc
annotations: {}
labels:
app: example
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
status: {}
- apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: example-deployment
labels:
app: example
spec:
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
app: example
spec:
containers:
- name: example
image: bitnami/python-example:0.0.1
ports:
- containerPort: 8000
name: http
livenessProbe:
httpGet:
path: /
port: http
httpHeaders:
- name: Host
value: app.example.com
initialDelaySeconds: 15
readinessProbe:
httpGet:
path: /
port: http
httpHeaders:
- name: Host
value: app.example.com
initialDelaySeconds: 5
resources: {}
volumeMounts:
- mountPath: /app/data
name: example-data
restartPolicy: Always
volumes:
- name: example-data
persistentVolumeClaim:
claimName: example-data-pvc
status: {}
kind: List
metadata: {}

View File

@@ -0,0 +1,22 @@
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)