diff --git a/manifests/conduit/emojivoto.yml b/manifests/conduit/emojivoto.yml new file mode 100644 index 000000000..6550f3752 --- /dev/null +++ b/manifests/conduit/emojivoto.yml @@ -0,0 +1,128 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: emojivoto +--- +apiVersion: apps/v1beta1 +kind: Deployment +metadata: + name: emoji-svc + namespace: emojivoto +spec: + replicas: 1 + selector: + matchLabels: + app: emoji-svc + template: + metadata: + labels: + app: emoji-svc + spec: + containers: + - name: emoji-svc + image: sz-pg-oam-docker-hub-001.tendcloud.com/library/emojivoto-emoji-svc:v1 + env: + - name: GRPC_PORT + value: "8080" + ports: + - name: grpc + containerPort: 8080 +--- +apiVersion: v1 +kind: Service +metadata: + name: emoji-svc + namespace: emojivoto +spec: + selector: + app: emoji-svc + clusterIP: None + ports: + - name: grpc + port: 8080 + targetPort: 8080 +--- +apiVersion: apps/v1beta1 +kind: Deployment +metadata: + name: voting-svc + namespace: emojivoto +spec: + replicas: 1 + selector: + matchLabels: + app: voting-svc + template: + metadata: + labels: + app: voting-svc + spec: + containers: + - name: voting-svc + image: sz-pg-oam-docker-hub-001.tendcloud.com/library/emojivoto-voting-svc:v1 + env: + - name: GRPC_PORT + value: "8080" + ports: + - name: grpc + containerPort: 8080 +--- +apiVersion: v1 +kind: Service +metadata: + name: voting-svc + namespace: emojivoto +spec: + selector: + app: voting-svc + clusterIP: None + ports: + - name: grpc + port: 8080 + targetPort: 8080 +--- +apiVersion: apps/v1beta1 +kind: Deployment +metadata: + name: web + namespace: emojivoto +spec: + replicas: 1 + selector: + matchLabels: + app: web + template: + metadata: + labels: + app: web + spec: + containers: + - name: emoji-svc + image: sz-pg-oam-docker-hub-001.tendcloud.com/library/emojivoto-web:v1 + env: + - name: WEB_PORT + value: "80" + - name: EMOJISVC_HOST + value: "emoji-svc.emojivoto:8080" + - name: VOTINGSVC_HOST + value: "voting-svc.emojivoto:8080" + - name: INDEX_BUNDLE + value: "dist/index_bundle.js" + ports: + - name: http + containerPort: 80 +--- +apiVersion: v1 +kind: Service +metadata: + name: web-svc + namespace: emojivoto +spec: + type: ClusterIP + selector: + app: web + ports: + - name: http + port: 80 + targetPort: 80 diff --git a/usecases/conduit-installation.md b/usecases/conduit-installation.md index a28078be0..bc6439a22 100644 --- a/usecases/conduit-installation.md +++ b/usecases/conduit-installation.md @@ -42,4 +42,172 @@ kubectl proxy --address='172.20.0.113' --port=8001 --accept-hosts='^*$' 在浏览器中访问将看到如下页面: -![Conduit dashboard](../images/conduit-dashboard.jpg) \ No newline at end of file +![Conduit dashboard](../images/conduit-dashboard.jpg) + +## Conduit inject + +Conduit注入的时候需要用到如下两个镜像: + +- gcr.io/runconduit/proxy:v0.1.0 +- gcr.io/runconduit/proxy-init:v0.1.0 + +我将其备份到了DockerHub: + +- jimmysong/runconduit-proxy:v0.1.0 +- jimmysong/runconduit-proxy-init:v0.1.0 + +查看conduit向yaml文件中注入了哪些配置,我们使用my-nginx.yaml为例: + +```bash +conduit inject --init-image sz-pg-oam-docker-hub-001.tendcloud.com/library/runconduit-proxy-init --proxy-image sz-pg-oam-docker-hub-001.tendcloud.com/library/runconduit-proxy my-nginx.yaml|kubectl apply -f - +``` + +**注意:**只需要指定镜像名称即可,tag与使用的conduit server版本相同,会自动注入。 + +my-nginx.yaml的内容如下: + +```yaml +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: my-nginx +spec: + replicas: 2 + template: + metadata: + labels: + run: my-nginx + spec: + containers: + - name: my-nginx + image: sz-pg-oam-docker-hub-001.tendcloud.com/library/nginx:1.9 + ports: + - containerPort: 80 +--- +apiVersion: v1 +kind: Service +metadata: + name: my-nginx + labels: + app: my-nginx +spec: + ports: + - port: 80 + protocol: TCP + name: http + selector: + run: my-nginx +``` + +Conduit自动注入后生成的新的yaml文件内容如下: + +```yaml +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + creationTimestamp: null + name: my-nginx +spec: + replicas: 2 + strategy: {} + template: + metadata: + annotations: + conduit.io/created-by: conduit/cli v0.1.0 + conduit.io/proxy-version: v0.1.0 + creationTimestamp: null + labels: + conduit.io/controller: conduit + conduit.io/plane: data + run: my-nginx + spec: + containers: + - image: sz-pg-oam-docker-hub-001.tendcloud.com/library/nginx:1.9 + name: my-nginx + ports: + - containerPort: 80 + resources: {} + - env: + - name: CONDUIT_PROXY_LOG + value: trace,h2=debug,mio=info,tokio_core=info + - name: CONDUIT_PROXY_CONTROL_URL + value: tcp://proxy-api.conduit.svc.cluster.local:8086 + - name: CONDUIT_PROXY_CONTROL_LISTENER + value: tcp://0.0.0.0:4190 + - name: CONDUIT_PROXY_PRIVATE_LISTENER + value: tcp://127.0.0.1:4140 + - name: CONDUIT_PROXY_PUBLIC_LISTENER + value: tcp://0.0.0.0:4143 + - name: CONDUIT_PROXY_NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: CONDUIT_PROXY_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: CONDUIT_PROXY_POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + image: sz-pg-oam-docker-hub-001.tendcloud.com/library/runconduit-proxy:v0.1.0 + imagePullPolicy: IfNotPresent + name: conduit-proxy + ports: + - containerPort: 4143 + name: conduit-proxy + resources: {} + securityContext: + runAsUser: 2102 + initContainers: + - args: + - -p + - "4143" + - -o + - "4140" + - -i + - "4190" + - -u + - "2102" + image: sz-pg-oam-docker-hub-001.tendcloud.com/library/runconduit-proxy-init:v0.1.0 + imagePullPolicy: IfNotPresent + name: conduit-init + resources: {} + securityContext: + capabilities: + add: + - NET_ADMIN + privileged: false +status: {} +--- +apiVersion: v1 +kind: Service +metadata: + name: my-nginx + labels: + app: my-nginx +spec: + ports: + - port: 80 + protocol: TCP + name: http + selector: + run: my-nginx +--- +``` + +## 部署示例应用 + +使用下面的命令部署官方提供的示例应用: + +```bash +curl https://raw.githubusercontent.com/rootsongjc/kubernetes-handbook/master/manifests/conduit/emojivoto.yml | conduit inject --init-image sz-pg-oam-docker-hub-001.tendcloud.com/library/runconduit-proxy-init --proxy-image sz-pg-oam-docker-hub-001.tendcloud.com/library/runconduit-proxy - --skip-inbound-ports=80 | kubectl apply -f - +``` + +**注意:**其中使用的镜像地址已经改为我的私有镜像仓库地址,大家使用时请注意修改。 + +TODO + +## 参考 + +[Getting started - conduit.io](https://conduit.io/getting-started/) \ No newline at end of file