I'm new to Kubernetes, so assume i don't know anything about deploying applications in it.
I have a Flask application and i'm trying to deploy from Azure Pipelines to GCP Kubernetes Cluster. I've already set up all the environment but, when i launch a new Release (from Azure Pipelines), i receive import errors at the GCP Kubernetes Logs screen, regarding the libraries i am using in my application. The main one that appears is:
ImportError: cannot import name 'anonymous_user_required' from 'flask_security'
Which is strange, since i have set up a Virtual Environment, with all the packages at requirements.txt
on my local machine and everything runs smoothly.
Below is my Dockerfile:
FROM python:3.7
ENV APP_HOME /app
ENV PORT 5000
WORKDIR $APP_HOME
COPY . $APP_HOME
RUN pip3 install -r requirements.txt
CMD ["python", "app.py"]
And my deployment.yaml:
apiVersion: v1
kind: Service
metadata:
name: app
spec:
ports:
- port: 80
targetPort: 8080
protocol: TCP
name: http
selector:
app: app
type: NodePort
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: app
spec:
backend:
serviceName: app
servicePort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: app
spec:
selector:
matchLabels:
app: app
replicas: 1
template:
metadata:
labels:
app: app
spec:
containers:
- name: app
image: APP_IMAGE
ports:
- containerPort: 8080
livenessProbe: # Used by deployment controller
httpGet:
path: /
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
readinessProbe: # Used by Ingress/GCLB
httpGet:
path: /
port: 8080
initialDelaySeconds: 3
periodSeconds: 5
resources:
limits:
memory: 1024Mi
requests:
memory: 768Mi
The APP_IMAGE is being set on my azure-pipelines.yml:
steps:
- task: CmdLine@1
displayName: 'Lock image version in deployment.yaml'
inputs:
filename: /bin/bash
arguments: '-c "awk ''{gsub(\"APP_IMAGE\", \"gcr.io/$(DockerImageName):$(Build.BuildId)\", $0); print}'' deployment.yaml > $(build.artifactstagingdirectory)/deployment.yaml"'
I followed Google Tutorial to deploy the application to a Kubernetes Cluster. The pipeline is working fine, it's publishing the Docker Image in the Google Container Registry and the Release from Azure is generating logs at the GCP Kubernetes screen.
Am i missing something at the deployment.yaml file? There is some extra configuration i have to do in GCP Kubernetes to make it work?