kubernetes ingress-nginx 0.15.0使用

1 创建相关资源

# kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml

此时ingress-nginx-controller还不能使用,container日志显示缺少ingress-nginx服务。

2 创建ingress-nginx服务

# kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/baremetal/service-nodeport.yaml

3 测试

# kubectl get svc  -o wide -n ingress-nginx
NAME                   TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE       SELECTOR
default-http-backend   ClusterIP   10.104.183.167   <none>        80/TCP         1h        app=default-http-backend
ingress-nginx          NodePort    10.108.244.205   <none>        80:32483/TCP   52m       app=ingress-nginx

# cat << EOF | kubectl create -f -
apiVersion: apps/v1beta1
kind: Deployment
metadata: 
  name: hello-world-deployment
spec: 
  replicas: 1
  template: 
    metadata: 
      labels: 
        app: hello-world
    spec: 
      containers: 
        - image: "gokul93/hello-world:latest"
          imagePullPolicy: Always
          name: hello-world-container
          ports: 
            - containerPort: 8080
---
apiVersion: v1
kind: Service
metadata: 
  name: hello-world-svc
spec: 
  ports: 
     -  port: 8080
        protocol: TCP
        targetPort: 8080
  selector: 
    app: hello-world
  type: NodePort
EOF

# cat << EOF | kubectl create -f -
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
  creationTimestamp: 2018-08-03T02:51:13Z
  generation: 2
  name: hello-world-ingress
  namespace: default
  resourceVersion: "3668608"
  selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/hello-world-ingress
  uid: 15b9c53b-96c8-11e8-9920-00505683568f
spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: hello-world-svc
          servicePort: 8080
        path: /
EOF

# curl k8s-node-ip:32483/hello
Hello world!hello
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值