kubernetesのmetricsをPrometheusを利用して収集する
- 事前準備
- クラスター構築
- RBAC設定
- コンテナ起動
- namespace設定
- configmap設定
- Prometheus
// ReadMeshConfig gets mesh configuration from a config file | |
func ReadMeshConfig(filename string) (*meshconfig.MeshConfig, error) { | |
yaml, err := ioutil.ReadFile(filename) | |
if err != nil { | |
return nil, multierror.Prefix(err, "cannot read mesh config file") | |
} | |
return model.ApplyMeshConfigDefaults(string(yaml)) | |
} |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: nginx-blue | |
namespace: sample-ns | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: nginx |
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: sample-ns | |
labels: | |
istio-injection: enabled |
apiVersion: networking.istio.io/v1alpha3 | |
kind: DestinationRule | |
metadata: | |
name: nginx-dr | |
namespace: default | |
spec: | |
host: nginx-svc.sample-ns.svc.cluster.local | |
subsets: | |
- name: blue | |
labels: |
apiVersion: networking.istio.io/v1alpha3 | |
kind: Gateway | |
metadata: | |
name: sample-gateway | |
namespace: default | |
spec: | |
selector: | |
istio: ingressgateway | |
servers: | |
- hosts: |
apiVersion: networking.istio.io/v1alpha3 | |
kind: VirtualService | |
metadata: | |
name: nginx-ds | |
namespace: default | |
spec: | |
gateways: | |
- sample-gateway | |
hosts: | |
- "sample.hoge.com" |
大抵のシンプル化はシステムから要素を取り除くことで実現できる
シンプル化は効率化である
コードを追加することと、取り除くことは同等に祝福される
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: nginx-svc | |
namespace: sample-ns | |
labels: | |
name: nginx | |
spec: | |
selector: | |
app: nginx |
apiVersion: networking.istio.io/v1alpha3 | |
kind: VirtualService | |
metadata: | |
name: nginx-ds | |
namespace: default | |
spec: | |
gateways: | |
- sample-gateway | |
hosts: | |
- "sample.hoge.com" |