(base) [root@node77 ingress-nginx]# helm install ingress-nginx ./ingress-nginx --namespace ingress-nginx NAME: ingress-nginx LAST DEPLOYED: Fri Aug 30 19:34:39 2024 NAMESPACE: ingress-nginx STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: The ingress-nginx controller has been installed. It may take a few minutes for the load balancer IP to be available. You can watch the status by running 'kubectl get service --namespace ingress-nginx ingress-nginx-controller --output wide --watch'
An example Ingress that makes use of the controller: apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: example namespace: foo spec: ingressClassName: nginx rules: - host: www.example.com http: paths: - pathType: Prefix backend: service: name: exampleService port: number: 80 path: / # This section is only required if TLS is to be enabled for the Ingress tls: - hosts: - www.example.com secretName: example-tls
If TLS is enabled for the Ingress, a Secret containing the certificate and key must also be provided:
apiVersion: v1 kind: Secret metadata: name: example-tls namespace: foo data: tls.crt: <base64 encoded cert> tls.key: <base64 encoded key> type: kubernetes.io/tls (base) [root@node77 ingress-nginx]# kubectl get service --namespace ingress-nginx ingress-nginx-controller --output wide --watch NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR ingress-nginx-controller LoadBalancer 10.96.1.190 <pending> 80:32702/TCP,443:32064/TCP 37s app.kubernetes.io/component=controller,app.kubernetes.io/instance=ingress-nginx,app.kubernetes.io/name=ingress-nginx
# 在此目录下 (base) [root@node77 sklearn_iris]# ls model.joblib sklearn-iris-model.yaml
# 执行命令 kubectl apply -f sklearn-iris-model.yaml
查看模型部署状态
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
(base) [root@node77 sklearn_iris]# kubectl get all -n test NAME READY STATUS RESTARTS AGE pod/sklearn-iris-1-predictor-84d48876bb-wvlm7 1/1 Running 0 40s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/sklearn-iris-1-predictor ClusterIP 10.96.0.243 <none> 80/TCP 40s
NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/sklearn-iris-1-predictor 1/1 1 1 40s
NAME DESIRED CURRENT READY AGE replicaset.apps/sklearn-iris-1-predictor-84d48876bb 1 1 1 40s
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE horizontalpodautoscaler.autoscaling/sklearn-iris-1-predictor Deployment/sklearn-iris-1-predictor <unknown>/80% 1 1 1 40s
查看 inferenceservice 状态
1 2 3
(base) [root@node77 sklearn_iris]# kubectl get inferenceservice -n test NAME URL READY PREV LATEST PREVROLLEDOUTREVISION LATESTREADYREVISION AGE sklearn-iris-1 http://sklearn-iris-1-test.example.com True 5m48s
使用 ingress 测试
查看 ingress-nginx 访问地址
1 2 3
(base) [root@node77 sklearn_iris]# kubectl get svc -n test NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE sklearn-iris-1-predictor ClusterIP 10.96.0.243 <none> 80/TCP 7m2s