实验test

apiVersion: v1
kind: Namespace
metadata:
  name: nginx-deploy
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-deploy
  namespace: nginx-deploy
  labels:
    app: nginx-deploy
spec:
  selector:
    app: nginx
  ports:
  - name: nginx-ports
    protocol: TCP
    port: 80
    targetPort: 80
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  namespace: nginx-deploy
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
#      nodeSelector:
#        kubernetes.io/hostname: g1-med-dev1-10
#        kubernetes.io/os: linux
#        ingress-nginx: "true"
#        node-role.kubernetes.io/10gbe: ""
#      tolerations:
#      - effect: NoSchedule
#        key: node.kubernetes.io/unschedulable
#        operator: Exists
#      - effect: NoSchedule
#        key: xueqing
#        operator: Equal
#        value: "xueqing"
#      - effect: PreferNoSchedule 
#        key: xueqing2
#        operator: Equal
#        value: "xueqing2"
      containers:
      - name: nginx
        image: hub.cloud.com/chenchaofeng/main:v1
        ports:
        - containerPort: 80
        resources:
          requests:
            cpu: 100m
            memory: 200Mi
          limits:
            cpu: 1
            memory: 1G
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-main
  namespace: nginx-deploy
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: chaofeng.apps.com
    http:
      paths:
        - path: /
          backend:
            serviceName: nginx-deploy
            servicePort: 80

main.go文件

package main

import (
    "fmt"
    "net/http"
    "time"
)

func IndexHandler(w http.ResponseWriter, r *http.Request) {
    time.Sleep(1 * time.Millisecond)
    fmt.Fprintln(w, "hello world")
}

func main() {
    http.HandleFunc("/", IndexHandler)
    http.ListenAndServe("0.0.0.0:80", nil)
}

访问ingress
for i in {1..1000};do curl chaofeng.apps.com -o /dev/null -s -w %{time_total};echo ;done &>a.txt;bash a.sh

a.sh文件如下所示:

#!/bin/bash

for i in `cat a.txt| xargs`;
do

  if [ `echo "$i > 0.005"|bc` -eq 1  ];then
	echo $i;
  fi
done
posted @ 2022-03-06 15:09  峰哥ge  阅读(78)  评论(2编辑  收藏  举报