Build the image

docker build -t docker.XXXX.com:15000/squid:v1.3 .
then push to a repository and adjust the image name in squid-deployment.yaml as appropriate. We use a deployment to specify that a certain number of squid instances should be running:
kubectl create -f squid-deployment.yaml
Create the squid service:
kubectl create -f squid-service.yaml
which enables the squid(s) to be accessed from within the Kubernetes cluster at `http://squid:3128`.

#### squid-deployment.yaml
apiVersion: apps/v1 kind: Deployment metadata: labels: app: squid name: squid spec: replicas: 1 selector: matchLabels: app: squid template: metadata: annotations: cni.projectcalico.org/ipAddrsNoIpam: '[""]' //设置静态IP labels: app: squid spec: containers: - name: squid image: docker.XXXX.com:15000/squid:v1.1 imagePullPolicy: IfNotPresent resources: requests: memory: "2.0Gi" cpu: "1000m" limits: memory: "2.0Gi" cpu: "1000m" env: - name: SQUID_CACHE_SIZE value: "70000" - name: SQUID_CACHE_MEM value: "2048" ports: - containerPort: 3128 protocol: TCP volumeMounts: - mountPath: /var/cache/squid name: squid-cache - mountPath: /var/log/squid name: squid-log livenessProbe: tcpSocket: port: 3128 initialDelaySeconds: 40 timeoutSeconds: 4 volumes: - name: squid-cache emptyDir: {} - name: squid-log emptyDir: {}

#### squid-service.yaml
apiVersion: v1 kind: Service metadata: labels: app: squid name: squid spec: ports: - port: 3128 selector: app: squid

#### squid-nodeport.yaml(如果不使用静态IP,可以使用nodeport进行暴露)
kind: Service apiVersion: v1 metadata: name: squid22 spec: ports: - name: squid22 nodePort: 31280 protocol: TCP port: 3128 targetPort: 3128 selector: app: squid type: NodePort ```


在非公网环境的主机下验证: mark

Squid后端日志记录: mark

本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!