如何在kubernetes的alertmanager pod中安装curl



我想在alertmanger pod中使用curl,如下所示:

curl www.google.com

它显示ash: curl: not found,所以我想安装curl:

/alertmanager # apk add curl
ash: apk: not found
/alertmanager # yum install curl
ash: yum: not found
/alertmanager # apt install curl
ash: apt: not found
/alertmanager # apt-get install curl
ash: apt-get: not found

那么我应该怎么做才能在这个吊舱中安装curl呢?这是我的yaml:

kind: Deployment
apiVersion: apps/v1
metadata:
name: alertmanager
namespace: kube-system
labels:
addonmanager.kubernetes.io/mode: Reconcile
k8s-app: alertmanager
kubernetes.io/cluster-service: 'true'
version: v0.14.0
annotations:
deployment.kubernetes.io/revision: '1'
spec:
replicas: 1
selector:
matchLabels:
k8s-app: alertmanager
version: v0.14.0
template:
metadata:
creationTimestamp: null
labels:
k8s-app: alertmanager
version: v0.14.0
annotations:
scheduler.alpha.kubernetes.io/critical-pod: ''
spec:
volumes:
- name: config-volume
configMap:
name: alertmanager-config
defaultMode: 420
- name: storage-volume
persistentVolumeClaim:
claimName: alertmanager
containers:
- name: prometheus-alertmanager
image: 'prom/alertmanager:v0.14.0'
args:
- '--config.file=/etc/config/alertmanager.yml'
- '--storage.path=/data'
- '--web.external-url=/'
ports:
- containerPort: 9093
protocol: TCP
resources:
limits:
cpu: 10m
memory: 50Mi
requests:
cpu: 10m
memory: 50Mi
volumeMounts:
- name: config-volume
mountPath: /etc/config
- name: storage-volume
mountPath: /data
readinessProbe:
httpGet:
path: '/#/status'
port: 9093
scheme: HTTP
initialDelaySeconds: 30
timeoutSeconds: 30
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
- name: prometheus-alertmanager-configmap-reload
image: 'jimmidyson/configmap-reload:v0.1'
args:
- '--volume-dir=/etc/config'
- '--webhook-url=http://localhost:9093/-/reload'
resources:
limits:
cpu: 10m
memory: 10Mi
requests:
cpu: 10m
memory: 10Mi
volumeMounts:
- name: config-volume
readOnly: true
mountPath: /etc/config
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
securityContext: {}
schedulerName: default-scheduler
priorityClassName: system-cluster-critical
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 25%
maxSurge: 25%
revisionHistoryLimit: 10
progressDeadlineSeconds: 600

查看警报管理器的Dockerfile,它使用的是未安装任何包管理器的busybox。你有两个选项

  1. 如果可能,请使用wget而不是curl
  2. 修改警报管理器的Dockerfile以使用alpine而不是busybox,并根据修改后的Dockerfle构建您自己的docker映像。alpine附带了apk包管理器,可用于通过apk add curl命令安装curl

最新更新