shell脚本相关附带k8s的ingress创建demo

编程

1.  可以通过echo来写文件,用在shell脚本,或者自动化中。

echo "aaaaa" > fileName.txt

echo "bbbbb" >> fileName.txt

cat fileName.txt

aaaaa
bbbbb

2. 通过输入直接执行命令

echo "

apiVersion: networking.k8s.io/v1beta1

kind: Ingress

metadata:

annotations:

nginx.ingress.kubernetes.io/rewrite-target: /$2

name: rewrite

namespace: default

spec:

rules:

- host: rewrite.bar.com

http:

paths:

- backend:

serviceName: http-svc

servicePort: 80

path: /something(/|$)(.*)

" | kubectl create -f -

rewrite.bar.com/something rewrites to rewrite.bar.com/

rewrite.bar.com/something/ rewrites to rewrite.bar.com/

rewrite.bar.com/something/new rewrites to rewrite.bar.com/new

ingress中的重定向写法

 

echo "

apiVersion: extensions/v1beta1

kind: Ingress

metadata:

annotations:

nginx.ingress.kubernetes.io/rewrite-target: /projectname

kubernetes.io/ingress.class: "nginx"

name: ingress-name

namespace: default

spec:

rules:

- host: aaa.bbb.com

http:

paths:

- backend:

serviceName: ccc-svc

servicePort: 8080

path: /projectname/api

tls:

- hosts:

- aaa.bbb.com

secretName: aaa-https-secret

" | kubectl create -f -

https://kubernetes.github.io/ingress-nginx/examples/rewrite/#app-root

以上是 shell脚本相关附带k8s的ingress创建demo 的全部内容, 来源链接: utcz.com/z/512807.html

回到顶部