5fc9fddfe17394881.jpg_fo742.png

Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nsfw-caffe
  namespace: test
  labels:
    app: nsfw-caffe
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nsfw-caffe
  template:
    metadata:
      name: nsfw-caffe
      labels:
        app: nsfw-caffe
    spec:
      containers:
        - name: nsfw-caffe
          image: registry.cn-hangzhou.aliyuncs.com/sre_pub/nsfw-caffe-cpu:20200423 
          imagePullPolicy: IfNotPresent
          command: ["python", "server.py", "8080"]
          ports:
            - name: http
              containerPort: 8080
              #HTTP调用API地址:http://ip:port/http://www.img.url//img.jpg
      restartPolicy: Always

svc

apiVersion: v1
kind: Service
metadata:
  name: nsfw-caffe
  namespace: test
  labels:
    app: nsfw-caffe
spec:
  type: NodePort
  selector:
    app: nsfw-caffe
  ports:
    - port: 8080
      name: http
      targetPort: 8080
      nodePort: 30037

测试

地址: http://ip:port/[url] (/后接资源url)
例如:

[root@master01 ~]# curl http://172.16.0.21:30037/https://pic4.zhimg.com/v2-8588c397ef76e531db5a16883813dc4b_xl.jpg
0.000943616556469351

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code