4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

kubernetesを知っている風に装えるショートカットはまるでtomato

Posted at

今回はkubernetes知っている風に思われると思われそうなショートカットについて書きます。
具体的にはgetとかで指定するリソースのショートカットですね。

pod -> ??

pod -> po
一番よく使われるであろう、kubectlコマンドkubectl get pod
pod部分を省略することができます!

節約できる文字は1文字にも関わらず、キーボード上でpoは岩手と秋田くらい近いですが、dは宮崎くらい離れているので、地味に便利です。

kubectl get podを4000回打てば、4000文字の削減になります。
これはもはや0.01secもとい1フレームを争う競技型kuberneterの方々にとっては、必須のショートカットと言えるでしょう。

$ kubectl get po
NAME                       READY   STATUS      RESTARTS   AGE
tomato-7d95f9bb8b-8ztpn    1/1     Running     0          2d1h

service -> ??

service -> svc
こいつはすごい!pod -> poが1文字だけだったのに対し、
こいつは7文字->3文字にタイプ数を減らすことができるすごいショートカットだ!!
...と言いたいところですが、serviceのショートカットがsvcってすごく覚えにくい気がします。
srvの方がよくね?...とか思ってしまうのは私だけでしょうか。

最初の頃はserviceのショートカットってことがわからず、ネットワーク系のことがわかる魔法の言葉だと思ってました。
service -> svcと思い出している時間を考えると、serviceと打った方が早いんじゃないか疑惑すらあります。

$ kubectl get svc
NAME          TYPE           CLUSTER-IP     EXTERNAL-IP     PORT(S)                      AGE
tomato        NodePort       10.0.76.99     <none>          10000:30922/TCP              24d

deployment -> deploy

deployment -> ??
Podたちの産みの親、deploymentのショートカット。
いくらPodをdeleteコマンドで削除しようとも、deploymentがいる限りPodは不滅なのです。

どうせならもっと短くできなかったのかとも思ってしまいますが、
mentを打たなくて良いメリットは大きいです。
つまりmentで毎回タイポする私のような人にオススメのショートカットです。

$ kubectl get deploy
NAME          READY   UP-TO-DATE   AVAILABLE   AGE
tomato        2/2     2            2           18d

ingress -> ??

ingress -> ing
勢いがありますね!!!!
外部ロードバランサのIngressのコントローラです。
しかし、ingressと打つのは意外と気持ち良いので(特にressの部分)、
ingと略さずあえてingressと打つ「ingress原理主義派閥」もいるとかいないとか。

$ kubectl get ing
NAME           HOSTS                                            ADDRESS   PORTS     AGE
tomato         tomatotomatotomato.japaneast.cloudapp.azure.com            80, 443   24d

horizontalpodautoscalers -> ??

horizontalpodautoscalers -> hpa
もはやショートカットが前提のようなこのリソース名。
horizontalpodautoscalersと何も見ずに打てる人は修行僧かなんかでしょうか。
Podのminとmaxを指定する水平スケールの定義です。

$ kubectl get hpa
NAME          REFERENCE                TARGETS   MINPODS   MAXPODS   REPLICAS   AGE
tomato        Deployment/tomato        1%/60%    2         4         2          28d

ショートカット一覧

で、結局のところショートカットってどれくらいあるの?
っていうのはこのコマンドを打てば出てきます。

kubectl api-resources

このコマンドさえ知ってればこの記事は必要ない説まであります。oh...
ちなみにNAMESPACEに属すものと属さないもの(--namespaced=true/false)があります。

あなたもここからお気に入りのショートカットを見つけてみてください!
kubernetesを知っている風に装うにはバッチリだと思います!
ではまた🙋‍♂️

$ kubectl api-resources
NAME                              SHORTNAMES   APIGROUP                       NAMESPACED   KIND
bindings                                                                      true         Binding
componentstatuses                 cs                                          false        ComponentStatus
configmaps                        cm                                          true         ConfigMap
endpoints                         ep                                          true         Endpoints
events                            ev                                          true         Event
limitranges                       limits                                      true         LimitRange
namespaces                        ns                                          false        Namespace
nodes                             no                                          false        Node
persistentvolumeclaims            pvc                                         true         PersistentVolumeClaim
persistentvolumes                 pv                                          false        PersistentVolume
pods                              po                                          true         Pod
podtemplates                                                                  true         PodTemplate
replicationcontrollers            rc                                          true         ReplicationController
resourcequotas                    quota                                       true         ResourceQuota
secrets                                                                       true         Secret
serviceaccounts                   sa                                          true         ServiceAccount
services                          svc                                         true         Service
azureassignedidentities                        aadpodidentity.k8s.io          true         AzureAssignedIdentity
azureidentities                                aadpodidentity.k8s.io          true         AzureIdentity
azureidentitybindings                          aadpodidentity.k8s.io          true         AzureIdentityBinding
azurepodidentityexceptions                     aadpodidentity.k8s.io          true         AzurePodIdentityException
certificates                                   admission.certmanager.k8s.io   false        AdmissionReview
clusterissuers                                 admission.certmanager.k8s.io   false        AdmissionReview
issuers                                        admission.certmanager.k8s.io   false        AdmissionReview
mutatingwebhookconfigurations                  admissionregistration.k8s.io   false        MutatingWebhookConfiguration
validatingwebhookconfigurations                admissionregistration.k8s.io   false        ValidatingWebhookConfiguration
customresourcedefinitions         crd,crds     apiextensions.k8s.io           false        CustomResourceDefinition
apiservices                                    apiregistration.k8s.io         false        APIService
controllerrevisions                            apps                           true         ControllerRevision
daemonsets                        ds           apps                           true         DaemonSet
deployments                       deploy       apps                           true         Deployment
replicasets                       rs           apps                           true         ReplicaSet
statefulsets                      sts          apps                           true         StatefulSet
tokenreviews                                   authentication.k8s.io          false        TokenReview
localsubjectaccessreviews                      authorization.k8s.io           true         LocalSubjectAccessReview
selfsubjectaccessreviews                       authorization.k8s.io           false        SelfSubjectAccessReview
selfsubjectrulesreviews                        authorization.k8s.io           false        SelfSubjectRulesReview
subjectaccessreviews                           authorization.k8s.io           false        SubjectAccessReview
horizontalpodautoscalers          hpa          autoscaling                    true         HorizontalPodAutoscaler
cronjobs                          cj           batch                          true         CronJob
jobs                                           batch                          true         Job
certificatesigningrequests        csr          certificates.k8s.io            false        CertificateSigningRequest
certificates                      cert,certs   certmanager.k8s.io             true         Certificate
challenges                                     certmanager.k8s.io             true         Challenge
clusterissuers                                 certmanager.k8s.io             false        ClusterIssuer
issuers                                        certmanager.k8s.io             true         Issuer
orders                                         certmanager.k8s.io             true         Order
leases                                         coordination.k8s.io            true         Lease
events                            ev           events.k8s.io                  true         Event
daemonsets                        ds           extensions                     true         DaemonSet
deployments                       deploy       extensions                     true         Deployment
ingresses                         ing          extensions                     true         Ingress
networkpolicies                   netpol       extensions                     true         NetworkPolicy
podsecuritypolicies               psp          extensions                     false        PodSecurityPolicy
replicasets                       rs           extensions                     true         ReplicaSet
nodes                                          metrics.k8s.io                 false        NodeMetrics
pods                                           metrics.k8s.io                 true         PodMetrics
alertmanagers                                  monitoring.coreos.com          true         Alertmanager
prometheuses                                   monitoring.coreos.com          true         Prometheus
prometheusrules                                monitoring.coreos.com          true         PrometheusRule
servicemonitors                                monitoring.coreos.com          true         ServiceMonitor
ingresses                         ing          networking.k8s.io              true         Ingress
networkpolicies                   netpol       networking.k8s.io              true         NetworkPolicy
runtimeclasses                                 node.k8s.io                    false        RuntimeClass
poddisruptionbudgets              pdb          policy                         true         PodDisruptionBudget
podsecuritypolicies               psp          policy                         false        PodSecurityPolicy
clusterrolebindings                            rbac.authorization.k8s.io      false        ClusterRoleBinding
clusterroles                                   rbac.authorization.k8s.io      false        ClusterRole
rolebindings                                   rbac.authorization.k8s.io      true         RoleBinding
roles                                          rbac.authorization.k8s.io      true         Role
priorityclasses                   pc           scheduling.k8s.io              false        PriorityClass
csidrivers                                     storage.k8s.io                 false        CSIDriver
csinodes                                       storage.k8s.io                 false        CSINode
storageclasses                    sc           storage.k8s.io                 false        StorageClass
volumeattachments                              storage.k8s.io                 false        VolumeAttachment

さいごに

ZEROBILLBANKでは一緒に働く仲間を募集中です。
なんとかjsとか、ブロックチェーンとか、kubernetesとかでいろんなAPIを作るお仕事。
今のところエンジニアは5人くらい。スタートアップだけど、結構ホワイトで働きやすいです。

ZEROBILLBANK JAPAN Inc.

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?