修改alertmanager-pvc.yaml
文件中的信息,然后应用YAML文件
cat > /opt/k8s/alertmanager/alertmanager-pvc.yaml <<EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: alertmanager-data-pvc
spec:
accessModes:
- ReadWriteMany
storageClassName: "nfs-storage"
resources:
requests:
storage: 5Gi
EOF
kubectl apply -f alertmanager-pvc.yaml
kubectl get pvc
部署ConfigMap
上传文件alertmanager.yml 到/opt/k8s/alertmanager/file/下
kubectl create configmap alertmanager-config \
--from-file=alertmanager.yml=/opt/k8s/alertmanager/file/alertmanager.yml
如需修改可使用kubectl edit 或者以下方式
删除现有的ConfigMap
kubectl delete configmap alertmanager-config
使用新的文件重新创建ConfigMap
kubectl create configmap alertmanager-config
–from-file=alertmanager.yml=/opt/k8s/alertmanager/file/alertmanager.yml
部署Deployment
修改alertmanager-Deployment.yaml
文件中的信息,然后应用YAML文件文章来源:https://www.toymoban.com/news/detail-859599.html
cat > /opt/k8s/alertmanager/alertmanager-Deployment.yaml <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: alertmanager
spec:
replicas: 1
selector:
matchLabels:
app: alertmanager
template:
metadata:
labels:
app: alertmanager
spec:
containers:
- name: alertmanager
image: prom/alertmanager:v0.27.0
args:
- "--config.file=/etc/alertmanager/alertmanager.yml"
ports:
- containerPort: 9093
volumeMounts:
- name: alertmanager-storage
mountPath: /alertmanager
- name: alertmanager-config
mountPath: /etc/alertmanager/alertmanager.yml
subPath: alertmanager.yml
volumes:
- name: alertmanager-storage
persistentVolumeClaim:
claimName: alertmanager-data-pvc
- name: alertmanager-config
configMap:
name: alertmanager
EOF
kubectl apply -f alertmanager-Deployment.yaml
kubectl get Deployment
部署Service
修改alertmanager-Service.yaml
文件中的信息,然后应用YAML文件文章来源地址https://www.toymoban.com/news/detail-859599.html
cat > /opt/k8s/alertmanager/alertmanager-Service.yaml <<EOF
apiVersion: v1
kind: Service
metadata:
name: alertmanager-service
spec:
type: NodePort
ports:
- port: 9093
targetPort: 9093
nodePort: 30093
selector:
app: alertmanager
EOF
kubectl apply -f alertmanager-Service.yaml
kubectl get Service
到了这里,关于k8s部署alertmanager的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!