Kubernetes Ingress Network Configuration instructions

Source: Internet
Author: User
Tags k8s kubernetes ingress


Docker Mirror Address

Default back-end service Image: registry.cn-qingdao.aliyuncs.com/kube8s/defaultbackend:1.0
Nginx-ingress-controller Service Image: registry.cn-qingdao.aliyuncs.com/kube8s/nginx-ingress-controller:0.8.3
Test Service Image: Registry.cn-qingdao.aliyuncs.com/icommon/hello-world:latest

Deploy Ingress-controlle default backend service


1. Configuration files and  grafana smtp configuration kubernetes


$ cat Default-http-backend.yamlapiversion:v1kind:replicationcontrollermetadata:name:default-http-backend        Namespace:kube-systemspec:replicas:1 selector:k8s-app:default-http-backend Template:metadata:labels: K8s-app:default-http-backend spec:terminationgraceperiodseconds:60 Containers:-Name:default -http-backend image:registry.cn-qingdao.aliyuncs.com/kube8s/defaultbackend:1.0 Livenessprobe:htt Pget:path:/healthz port:8080 scheme:http initialdelayseconds:30 ti            Meoutseconds:5 ports:-containerport:8080 resources:limits:cpu:10m Memory:20mi requests:cpu:10m memory:20mi---ApiVersion:v1kind:Servicemetadata:nam E:default-http-backend labels:k8s-app:default-http-backend namespace:kube-systemspec:ports:-port:80 Targ etport:8080 Selector:k8s-app: Default-http-backend


2. Start the service kubernetes pod configuration file


kubectl create -f default-http-backend.yaml


3. Verification


curl http://$pod_ip:8080/healthz


Return OK, indicating successful deployment
POD_IP, you can use kubectl describe to get


Deploying Nginx-ingress-controller Services


1. Configuration files


$ cat Ingress-controller.yamlapiversion:v1kind:replicationcontrollermetadata:name:nginx-ingress-controller Namespace:kube-system labels:k8s-app:nginx-ingress-lbspec:replicas:1 selector:k8s-app:nginx-ingress-lb te MPLATE:METADATA:LABELS:K8S-APP:NGINX-INGRESS-LB name:nginx-ingress-lb Spec: #跟apiserver The serviceaccount used by the communication is not default and requires a Token,serviceaccount file see below Serviceaccount:admin-user Serviceaccountname:adm In-user hostnetwork:true #解决端口无法映射问题 terminationgraceperiodseconds:60 containers:-Image:regis          try.cn-qingdao.aliyuncs.com/kube8s/nginx-ingress-controller:0.8.3 name:nginx-ingress-lb ReadinessProbe: Httpget:path:/healthz port:80 scheme:http Livenessprobe:httpge T:path:/healthz port:80 scheme:http initialdelayseconds:10 Timeout Seconds:1 ENV:- Name:pod_name Valuefrom:fieldref:fieldpath:metadata.name-name:pod_ NAMESPACE Valuefrom:fieldref:fieldpath:metadata.namespace-name:kuber          Netes_master value:https://192.168.6.110:6443 #kubeapiserver Address ports:-containerport:80        hostport:80-containerport:443 hostport:443 args:-/nginx-ingress-controller ---default-backend-service=$ (Pod_namespace)/default-http-backend


ServiceAccount file


$ cat admin-user.yamlapiVersion: v1kind: ServiceAccountmetadata:  name: admin-user  namespace: kube-system---apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRoleBindingmetadata:  name: admin-userroleRef:  apiGroup: rbac.authorization.k8s.io  kind: ClusterRole  name: cluster-adminsubjects:- kind: ServiceAccount  name: admin-user  namespace: kube-system


2. Start the service 


kubectl create -f admin-user.yamlkubectl create -f ingress-controller.yaml


3. Verification


curl http://$node_ip:8080/healthz


Return OK, indicating successful deployment


Deploying the Hello-world test service


1. Configuration files and configure docker registry in kubernetes


$cat hello-world.yamlapiVersion: extensions/v1beta1kind: Deploymentmetadata:  name: hello-world spec:  replicas: 3  template:    metadata:      labels:        k8s-app: hello-world     spec:      containers:      - name: hello-world         image: registry.cn-qingdao.aliyuncs.com/icommon/hello-world:latest ---apiVersion: v1kind: Servicemetadata:  name: hello-world spec:  type: NodePort  ports:  - port: 8080    targetPort: 8080        nodePort: 31180  selector:    k8s-app: hello-world


2. Start the service,kubernetes application configuration


kubectl create -f hello-world.yaml


3. Verification Services,pod configuration kubernetes


curl http://$node_ip:31180/hello-world/index.jsp


Returns the following to indicate a successful deployment


<body>
</body>

Deploying Ingress Services


1. Configuration files


$ cat ingress.yamlapiVersion: extensions/v1beta1kind: Ingressmetadata:  name: hello-ingressspec:  rules:     - http:        paths:        - path: /hello-world/index.jsp          backend:            serviceName: hello-world            servicePort: 8080


2. Start the service


kubectl create -f ingress.yaml


3. Verification


curl http://$node_ip/hello-world/index.jsp


Returns the following to indicate a successful deployment configuration management kubernetes


<body>
</body>


Kubernetes Ingress Network Configuration instructions


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.