https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/#customresourcedefinitions


ThirdPartyResource 가 1.8부터 custom resource definition으로 대체되었다.


관련 예시이다.


 


$ vi crd.yaml

apiVersion: apiextensions.k8s.io/v1beta1

kind: CustomResourceDefinition

metadata:

  name: crontabs.training.lfs458.com

    # This name must match names below.

    # <plural>.<group> syntax

spec:

  scope: Cluster #Could also be Namespaced

  group: training.lfs458.com

  version: v1

  names:

    kind: CronTab #Typically CamelCased for resource manifest

    plural: crontabs #Shown in URL

    singular: crontab #Short name for CLI alias

    shortNames:

    - ct #CLI short name




$ kubectl create -f crd.yaml



$  kubectl get crd

NAME                           AGE

crontabs.training.lfs458.com   4m



$ kubectl describe crd crontab

Name:         crontabs.training.lfs458.com

Namespace:

Labels:       <none>

Annotations:  <none>

API Version:  apiextensions.k8s.io/v1beta1

Kind:         CustomResourceDefinition

Metadata:

  Creation Timestamp:  2018-12-18T05:49:45Z

  Generation:          1

  Resource Version:    3992526

  Self Link:           /apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/crontabs.training.lfs458.com

  UID:                 b92d0073-0288-11e9-9a46-fa163e964181

Spec:

  Group:  training.lfs458.com

  Names:

    Kind:       CronTab

    List Kind:  CronTabList

    Plural:     crontabs

    Short Names:

      ct

    Singular:  crontab

  Scope:       Cluster

  Version:     v1

Status:

  Accepted Names:

    Kind:       CronTab

    List Kind:  CronTabList

    Plural:     crontabs

    Short Names:

      ct

    Singular:  crontab

  Conditions:

    Last Transition Time:  2018-12-18T10:49:45Z

    Message:               no conflicts found

    Reason:                NoConflicts

    Status:                True

    Type:                  NamesAccepted

    Last Transition Time:  2018-12-18T10:49:45Z

    Message:               the initial names have been accepted

    Reason:                InitialNamesAccepted

    Status:                True

    Type:                  Established

Events:                    <none>


$ vi  new-crontab.yaml

apiVersion: "training.lfs458.com/v1"

  # This is from the group and version of new CRD

kind: CronTab

  # The kind from the new CRD

metadata:

  name: new-cron-object

spec:

  cronSpec: "*/5 * * * *"

  image: some-cron-image

    #Does not exist



$ kubectl create -f new-crontab.yaml



$ kubectl get CronTab

NAME              AGE

new-cron-object   4m


$ kubectl get ct

NAME              AGE

new-cron-object   4m


$ kubectl describe ct


Name:         new-cron-object

Namespace:

Labels:       <none>

Annotations:  <none>

API Version:  training.lfs458.com/v1

Kind:         CronTab

Metadata:

  Cluster Name:

  Creation Timestamp:  2018-12-18T10:52:21Z

  Resource Version:    3992891

  Self Link:           /apis/training.lfs458.com/v1/new-cron-object

  UID:                 16295359-0289-11e9-9a46-fa163e964181

Spec:

  Cron Spec:  */5 * * * *

  Image:      some-cron-image

Events:       <none>



$ kubectl delete -f crd.yaml

$ kubectl get CronTab
No resources found.

$ kubectl get ct

No resources found.


Posted by '김용환'
,



<로그 파일 위치>



kubernetes의 마스터(master) 노드에서 로그 위치는 다음과 같다.


1. API : /var/log/kube-apiserver.log

2. 스케줄 : /var/log/kube-scheduler.log

3. 복제 관리 : /var/log/kube-controller-manager.log

4. 컨테이너 로그 : /var/log/containers/

5. pod : /var/log/pods/



워커(worker) 노드의 로그는 다음과 같다.


1. 노드에서 실행 중인 컨테이너 : /var/log/kubelet.log

2. 서비스 로드 밸런싱 : /var/log/kube-proxy.log





<pod bash 연결>

$ kubectl exec <POD-NAME> -c <CONTAINER-NAME> -- <COMMAND>
$ kubectl run -it --rm --restart=Never busybox --image=busybox /bin/bash





<pod 로그 보기>


$ kubectl get po --all-namespaces

...

kube-apiserver-k8s-master1

...

$ kubectl -n kube-system logs kube-apiserver-k8s-master1

..



이외 디버깅 방법


https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/


https://kubernetes.io/docs/tasks/debug-application-cluster/determine-reason-pod-failure/


Posted by '김용환'
,




Label

- 개체의 메타 데이터를 설정 : Kubernetes 클러스터에서 개체를 그룹화/목록/작업 용

- Pod과 ReplicaSet 등의 Kubernetes 개체에 부여하는 키-값 쌍.



Annotation

- Label과 마찬가지로 키-값, 개체의 메타 데이터를 저장 : 자동화 툴 또는 클라이언트 라이브러리에서 사용하는 메타 데이터를 저장하는 키-값 스토어.객체에 대한 임의의 정보를 저장

- 식별 정보는 아니다. 따라서 히스토리, 스케줄 정책, 부가 정보 등등을 저장한다

Posted by '김용환'
,



앤서블 설치 방법


1. 패키지 관리자 (brew나 pip 등)를 사용한다.


$ sudo pip install ansible



2. virtualenv에 연동할 수 있다.


$ wget https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get-pipsi.py 

$ python get-pipsi.py 

$ pipsi install ansible





'Ansible-Puppet-Chef' 카테고리의 다른 글

ansible-galaxy  (0) 2019.01.14
[ansible] ubuntu 16에 no_proxy가 안먹는 이슈가  (0) 2019.01.09
[ansible] lineinfile  (0) 2018.07.05
[ansible] 배포될 서버의 호스트명 얻는 방법  (0) 2018.04.02
[ansible] become  (0) 2018.02.01
Posted by '김용환'
,