三:kubernetesリソースリスト定義の入門


RESTful:
GET,PUT,DELETE,POST。。。
kubectl run ,get ,edit ...
アセット:オブジェクトおぶじぇくと
workload: Pod,ReplicaSet,Deployment,StatefulSet,DeamonSet,Job,Cronjob...
       :Service,Ingress,。。。
     :Volume,CSI
    ConfigMap,Secret
    DownwardAPI
      
    Namespace,Node,Role,ClusterRole,RoleBinding,ClusterRoleBinding
      
    HPA,PodTemplate,LimitRange

  pod yaml    
    [root@ll-sas01 ~]# kubectl get pod myapp-848b5b879b-2bgl6 -o yaml
リソースの作成方法:apiserverはJSON形式のリソース定義のみを受信
yamlフォーマットは構成リストを提供し、apiserverは自動的にjsonフォーマットに変換してから提出することができます.
ほとんどのリソースの構成リスト:
apiVersion:groupname/version
       kubectl api-versions
kind:    
metadata:   
    name
    namespace
    label
    annotations
    ownerReferences
    selfLink
    uid
    resourceVersion
         PATH/api/GROUP/VERSION/namespace/NAMESPACE/TYPE/NAMEspec:     ,disired  statestatus :    ,current state,             kubectl explain pods   :  pods     pods  metadata  kubectl explain pods.metadata
簡単にyamlを使用してpodを定義してvim pod-demoを作成します.yaml
apiVersion: v1
kind: Pod
metadata:
  name: pod-demo
  namespace: default
  labels:
    app: myapp
    tier: frontend
spec:
  containers:
  - name: myapp
    image: ikubernetes/myapp:v1
  - name: busybox
    image: busybox:latest
    command:
    - "/bin/sh"
    - "-c"
    - "sleep 3600"
 
yamlに基づいてpodを作成する
[root@ll-sas01 ~/manifests]# kubectl create -f pod-demo.yaml 
[root@ll-sas01 ~/manifests]# kubectl get pods
NAME                             READY     STATUS    RESTARTS   AGE
pod-demo                         2/2       Running   0          2m
コンテナ情報の表示:
[root@ll-sas01 ~/manifests]# kubectl describe pod pod-demo
yamlログの表示:
[root@ll-sas01 ~/manifests]# kubectl logs pod-demo myapp
10.244.0.0 - - [20/Sep/2018:02:49:43 +0000] "GET / HTTP/1.1" 200 65 "-" "curl/7.29.0" "-"
10.244.0.0 - - [20/Sep/2018:02:49:45 +0000] "GET / HTTP/1.1" 200 65 "-" "curl/7.29.0" "-"
10.244.0.0 - - [20/Sep/2018:02:49:46 +0000] "GET / HTTP/1.1" 200 65 "-" "curl/7.29.0" "-"
[root@ll-sas01 ~/manifests]# kubectl logs pod-demo busybox
/bin/sh: can't create /usr/share/nginx/html/index.html: nonexistent directory
コンテナに入る:
[root@ll-sas01 ~/manifests]# kubectl exec -it pod-demo -c myapp -- /bin/sh
コンテナを削除するには
[root@ll-sas01 ~/manifests]# kubectl delete pod pod-demo
  
[root@ll-sas01 ~/manifests]# kubectl delete -f pod-demo.yaml