码迷,mamicode.com
首页 > 其他好文 > 详细

test

时间:2020-10-27 11:36:36      阅读:16      评论:0      收藏:0      [点我收藏+]

标签:docke   secret   ada   UNC   dock   b2c   class   match   deploy   

.drone.yml

技术图片
 1 kind: pipeline
 2 name: default
 3 steps:
 4   - name: test
 5     image: python:3.7-alpine
 6     commands:
 7       - "python test.py"
 8 
 9   # - name: publish
10   #   image: plugins/docker
11   #   settings:
12   #       mirror: https://cm2sd473.mirror.aliyuncs.com
13   #       repo: registry:5000/flask
14   #       registry: registry:5000
15   #       insecure: true
16   #       tags: [ "${DRONE_COMMIT_SHA:0:7}","latest" ]    
17   #       password:
18   #         from_secret: docker_password
19   #       username:
20   #         from_secret: docker_username
21        
22   - name: deliver
23     image: sinlead/drone-kubectl
24     network_mode: bridge
25     environment:
26         PLUGIN_KUBERNETES_SERVER: https://minikube:8443
27         PLUGIN_KUBERNETES_USER: minikube
28         # PLUGIN_KUBERNETES_TOKEN: minikube
29         # PLUGIN_KUBERNETES_CERT: minikube
30     settings:
31         mirror: https://cm2sd473.mirror.aliyuncs.com
32         kubernetes_server:
33           from_secret: k8s_server
34         kubernetes_cert:
35           from_secret: k8s_cert
36         kubernetes_token:
37           from_secret: k8s_token
38     commands:   
39         # - env
40         - kubectl config view
41         - kubectl version --short
42         # - kubectl create deployment flask-deployment --image=localhost:5000/flask:latest --output=yaml
43         - kubectl apply -f deployment.yml
View Code

Dockerfile 

技术图片
1 FROM python:3.7-alpine 
2 WORKDIR /app 
3 COPY requirements.txt /app
4 RUN pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
5 COPY . /app 
6 ENTRYPOINT ["python3"] 
7 CMD ["app.py"]
View Code

app.py

技术图片
1 from flask import Flask
2 app = Flask(__name__)
3 
4 @app.route(‘/‘)
5 def hello():
6     return "Hello World!"
7 
8 if __name__ == ‘__main__‘:
9     app.run(host=‘0.0.0.0:8081‘)
View Code

deployment.yml

技术图片
 1 apiVersion: apps/v1
 2 kind: Deployment
 3 metadata:
 4   name: flask-deployment
 5   labels:
 6     app: flask
 7 spec:
 8   replicas: 3
 9   selector:
10     matchLabels:
11       app: flask
12   template:
13     metadata:
14       labels:
15         app: flask
16     spec:
17       containers:
18       - name: flask
19         image: registry:5000/flask:latest
20         ports:
21         - containerPort: 80
View Code

docker-compose.yml

技术图片
1 version: ‘3‘ 
2 services: 
3   web: 
4     build: app 
5     ports: 
6       - ‘5000:5000‘
View Code

requirements.txt

技术图片
1 flask
View Code

test.py

技术图片
1 print(‘hello, python!test‘)
View Code

 

test

标签:docke   secret   ada   UNC   dock   b2c   class   match   deploy   

原文地址:https://www.cnblogs.com/kulou/p/13881416.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!