Skip to content

Commit dcf93a3

Browse files
committed
add kubernetes
1 parent 30d5b0c commit dcf93a3

15 files changed

+316
-141
lines changed

Dockerfile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
FROM python:3.6-alpine
1+
FROM nginx:alpine
22
WORKDIR /app
3+
RUN apk add --no-cache --virtual .build-deps g++ python3-dev libffi-dev \
4+
openssl-dev libxml2-dev libxslt-dev gcc musl-dev py3-pip && \
5+
apk add --no-cache --update python3 && \
6+
pip3 install --upgrade pip setuptools
7+
COPY requirements.txt .
8+
RUN pip3 install -r requirements.txt && \
9+
apk del g++ gcc musl-dev libxml2-dev
310
COPY . .
411
# RUN pip install -r requirements.txt -i https://pypi.douban.com/simple
5-
RUN apk add --no-cache libxml2-dev libxslt-dev gcc musl-dev && \
6-
pip install -r requirements.txt && \
7-
apk del gcc musl-dev libxml2-dev
812
VOLUME ["/app/proxypool/crawlers/private"]
913
CMD ["supervisord", "-c", "supervisord.conf"]

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,7 @@ class Daili66Crawler(BaseCrawler):
341341
342342
## 部署
343343
344-
本项目提供了 Kubernetes 部署脚本,如需部署到 Kubernetes,执行如下命令即可:
345-
346-
```shell script
347-
cat deployment.yml | sed 's/\${TAG}/latest/g' | kubectl apply -f -
348-
```
344+
本项目提供了 Kubernetes 部署脚本,如需部署到 Kubernetes,请参考 [kubernetes](./kubernetes)。
349345
350346
## 待开发
351347

build.yml renamed to build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
# restart: always
99
proxypool:
1010
build: .
11-
image: "germey/proxypool"
11+
image: "germey/proxypool:master"
1212
container_name: proxypool
1313
ports:
1414
- "5555:5555"

deployment.yml

Lines changed: 0 additions & 99 deletions
This file was deleted.

ingress.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

kubernetes/.helmignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
24+
image/

kubernetes/Chart.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: v2
2+
name: proxypool
3+
description: A Efficient Proxy Pool
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# Keywords about this application.
16+
keywords:
17+
- proxypool
18+
19+
# This is the chart version. This version number should be incremented each time you make changes
20+
# to the chart and its templates, including the app version.
21+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
22+
version: 0.1.0
23+
24+
# This is the version number of the application being deployed. This version number should be
25+
# incremented each time you make changes to the application. Versions are not expected to
26+
# follow Semantic Versioning. They should reflect the version the application is using.
27+
appVersion: 1.16.0

kubernetes/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Kubernetes 部署
2+
3+
这是用来快速部署本代理池的 Helm Charts。
4+
5+
首先需要有一个 Kubernetes 集群,其次需要安装 Helm,确保 helm 命令可以正常运行。
6+
7+
## 安装
8+
9+
安装直接使用 helm 命令在本文件夹运行即可,使用 `-n` 可以制定 NameSpace。
10+
11+
```shell
12+
helm install proxypool-app . -n scrape
13+
```
14+
15+
其中 proxypool-app 就是应用的名字,可以任意取名,它会用作代理池 Deplyment 的名称。
16+
17+
如果需要覆盖变量,可以修改 values.yaml 文件,执行如下命令安装:
18+
19+
```shell
20+
helm install proxypool-app . -f values.yaml -n scrape
21+
```
22+
23+
## 更新
24+
25+
如果需要更新配置,可以修改 values.yaml 文件,执行如下命令更新版本:
26+
27+
```shell
28+
helm upgrade proxypool-app . -f values.yaml -n scrape
29+
```
30+
31+
## 卸载
32+
33+
如果不想使用了,可以只用 uninstall 命令卸载:
34+
35+
```shell
36+
helm uninstall proxypool-app -n scrape
37+
```

kubernetes/templates/_helpers.tpl

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "proxypool.name" -}}
6+
{{- default .Chart.Name .Values.name | trunc 63 | trimSuffix "-" }}
7+
{{- end }}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "proxypool.fullname" -}}
15+
{{- if .Values.fullname }}
16+
{{- .Values.fullname | trunc 63 | trimSuffix "-" }}
17+
{{- else }}
18+
{{- $name := default .Chart.Name .Values.name }}
19+
{{- if contains $name .Release.Name }}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
21+
{{- else }}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
23+
{{- end }}
24+
{{- end }}
25+
{{- end }}
26+
27+
28+
{{/*
29+
Create chart name and version as used by the chart label.
30+
*/}}
31+
{{- define "proxypool.chart" -}}
32+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
33+
{{- end }}
34+
35+
{{/*
36+
Common labels
37+
*/}}
38+
{{- define "proxypool.labels" -}}
39+
helm.sh/chart: {{ include "proxypool.chart" . }}
40+
{{ include "proxypool.selectorLabels" . }}
41+
{{- if .Chart.AppVersion }}
42+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
43+
{{- end }}
44+
app.kubernetes.io/managed-by: {{ .Release.Service }}
45+
{{- end }}
46+
47+
{{/*
48+
Selector labels
49+
*/}}
50+
{{- define "proxypool.selectorLabels" -}}
51+
app.kubernetes.io/name: {{ include "proxypool.fullname" . }}
52+
app.kubernetes.io/instance: {{ .Release.Name }}
53+
{{- end }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "proxypool.fullname" . }}
5+
labels:
6+
{{- include "proxypool.labels" . | nindent 4 }}
7+
spec:
8+
replicas: {{ .Values.deployment.replicas }}
9+
revisionHistoryLimit: {{ .Values.deployment.revisionHistoryLimit }}
10+
selector:
11+
matchLabels:
12+
{{- include "proxypool.labels" . | nindent 8 }}
13+
template:
14+
metadata:
15+
labels:
16+
{{- include "proxypool.labels" . | nindent 8 }}
17+
spec:
18+
restartPolicy: {{ .Values.deployment.restartPolicy }}
19+
containers:
20+
- name: {{ include "proxypool.fullname" . }}
21+
image: {{ .Values.deployment.image }}
22+
ports:
23+
- containerPort: 5555
24+
protocol: TCP
25+
imagePullPolicy: {{ .Values.deployment.imagePullPolicy }}
26+
resources:
27+
{{- toYaml .Values.deployment.resources | nindent 12 }}
28+
env:
29+
{{- toYaml .Values.deployment.env | nindent 12 }}

0 commit comments

Comments
 (0)