增加 构建和部署文件
This commit is contained in:
parent
124c7fbdcd
commit
626b35ac84
19
Dockerfile
Normal file
19
Dockerfile
Normal file
@ -0,0 +1,19 @@
|
||||
# Use the official Golang image as a base image
|
||||
FROM golang:1.22.5-alpine
|
||||
|
||||
# Set the working directory inside the container
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the Go application into the container
|
||||
COPY . .
|
||||
|
||||
RUN go env -w GO111MODULE=on && go env -w GOPROXY=https://goproxy.cn
|
||||
|
||||
# Build the Go application
|
||||
RUN go build -ldflags="-s -w" -o app main.go
|
||||
|
||||
|
||||
FROM alpine:latest
|
||||
COPY --from=0 /app/app /app/app
|
||||
|
||||
CMD ["/app/app"]
|
92
manifest.yaml
Normal file
92
manifest.yaml
Normal file
@ -0,0 +1,92 @@
|
||||
# deployment.yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: k8s-web-status
|
||||
namespace: websites
|
||||
labels:
|
||||
app: web-status
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: web-status
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: web-status
|
||||
spec:
|
||||
serviceAccountName: web-status-sa
|
||||
containers:
|
||||
- name: web-status
|
||||
image: registry.leafdev.top/leaf/go-k8s-deployment-status:v0.0.1
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
env:
|
||||
- name: KUBERNETES_SERVICE_HOST
|
||||
value: "kubernetes.default.svc"
|
||||
- name: KUBERNETES_SERVICE_PORT
|
||||
value: "443"
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: web-status-configmap
|
||||
---
|
||||
# configMap.yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: web-status-configmap
|
||||
namespace: websites
|
||||
labels:
|
||||
app: web-status
|
||||
data:
|
||||
NAMESPACES: "websites"
|
||||
---
|
||||
# service.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: web-status-service
|
||||
namespace: websites
|
||||
spec:
|
||||
selector:
|
||||
app: web-status
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 8080
|
||||
type: ClusterIP
|
||||
---
|
||||
# serviceaccount.yaml
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: web-status-sa
|
||||
namespace: websites
|
||||
---
|
||||
# role.yaml
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
namespace: websites
|
||||
name: web-status-role
|
||||
rules:
|
||||
- apiGroups: ["", "apps", "extensions"]
|
||||
resources: ["deployments"]
|
||||
verbs: ["get", "list"]
|
||||
---
|
||||
# rolebinding.yaml
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: web-status-rb
|
||||
namespace: websites
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: web-status-sa
|
||||
namespace: websites
|
||||
roleRef:
|
||||
kind: Role
|
||||
name: web-status-role
|
||||
apiGroup: rbac.authorization.k8s.io
|
Loading…
Reference in New Issue
Block a user