我有简单的单页golang web应用程序,我正在尝试迁移到istio .
我的prod设置(通过nginx入口):
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: goapp
annotations:
kubernetes.io/ingress.class: nginx
kubernetes.io/tls-acme: "true"
spec:
tls:
- hosts:
- mycustomapp.mycustomapp.com
secretName: go-tls
rules:
- host: mycustomapp.mycustomapp.com
http:
paths:
- path: /
backend:
serviceName: mycustomapp
servicePort: 80
我正在尝试为istio构建至少http配置
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: goapp
annotations:
kubernetes.io/ingress.class: istio
spec:
rules:
- host: mycustomapp.mycustomapp.com
http:
paths:
- path: /
backend:
serviceName: mycustomapp
servicePort: 80
但我总是通过istio lb在istio lb上获得404,只安装了istio 0.7.1 . 像bookinfo和httpbin这样的样本效果很好
申请名称:
kind: Deployment
apiVersion: apps/v1
metadata:
labels:
k8s-app: mycustomapp
name: mycustomapp
spec:
replicas: 1
selector:
matchLabels:
k8s-app: mycustomapp
template:
metadata:
labels:
k8s-app: mycustomapp
spec:
containers:
- name: mycustomapp
image: xxxx.azurecr.io/mycustomapp:999
ports:
- containerPort: 80
protocol: TCP
imagePullSecrets:
- name: xxxx
serviceAccountName: mycustomapp
---
kind: Service
apiVersion: v1
metadata:
annotations:
prometheus.io/scrape: 'true'
labels:
k8s-app: mycustomapp
name: mycustomapp
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 80
selector:
k8s-app: mycustomapp
1 回答
要消除您的情况下的404错误,应该足以将正确的端口名称添加到服务和部署YAML文件,并将istio sidecar添加到部署YAML文件 . 然后,您应该重新部署所有已更改的文件 .
也许您可能需要在服务和部署中添加标签
app: mycustomapp
,但我不确定它是必需的还是可选的 .以下是具有正确端口名称的service.yaml文件的示例(有关您可以阅读的端口名称的更多信息here):
确保部署文件中还包含正确的端口名称 .
您可以按照以下步骤手动将istio边车添加到容器中:
下载并解压缩最新的istio版本,适用于您的操作系统https://github.com/istio/istio/releases
将目录更改为istio包 . 例如,如果包是istio-0.7
cd istio-0.7
kubectl create -f install/kubernetes/istio-sidecar-injector-configmap-release.yaml --dry-run -o=jsonpath='{.data.config}' > inject-config.yaml
kubectl -n istio-system get configmap istio -o=jsonpath='{.data.mesh}' > mesh-config.yaml
bin/istioctl kube-inject \ --injectConfigFile inject-config.yaml \ --meshConfigFile mesh-config.yaml \ --filename path/to/original/deployment.yaml \ --output deployment-injected.yaml
如果您想要自动侧车注射,请按照this手册进行操作 .
您可以检查是否已将边车注入部署中: