Skip to content

Instantly share code, notes, and snippets.

@rimusz
Forked from ipedrazas/deployment.go
Created June 25, 2018 13:22
Show Gist options
  • Save rimusz/d650fc3da56f0e49df5978fc45ce3f67 to your computer and use it in GitHub Desktop.
Save rimusz/d650fc3da56f0e49df5978fc45ce3f67 to your computer and use it in GitHub Desktop.
From kubectl to GO lang type
// Generated by https://quicktype.io
type Deployment struct {
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Metadata DeploymentMetadata `json:"metadata"`
Spec DeploymentSpec `json:"spec"`
Status Status `json:"status"`
}
type DeploymentMetadata struct {
Annotations Annotations `json:"annotations"`
CreationTimestamp string `json:"creationTimestamp"`
Generation int64 `json:"generation"`
Labels PurpleLabels `json:"labels"`
Name string `json:"name"`
Namespace string `json:"namespace"`
ResourceVersion string `json:"resourceVersion"`
SelfLink string `json:"selfLink"`
Uid string `json:"uid"`
}
type Annotations struct {
DeploymentKubernetesIoRevision string `json:"deployment.kubernetes.io/revision"`
}
type PurpleLabels struct {
App string `json:"app"`
Chart string `json:"chart"`
Heritage string `json:"heritage"`
Release string `json:"release"`
}
type DeploymentSpec struct {
ProgressDeadlineSeconds int64 `json:"progressDeadlineSeconds"`
Replicas int64 `json:"replicas"`
RevisionHistoryLimit int64 `json:"revisionHistoryLimit"`
Selector Selector `json:"selector"`
Strategy Strategy `json:"strategy"`
Template Template `json:"template"`
}
type Selector struct {
MatchLabels MatchLabelsClass `json:"matchLabels"`
}
type MatchLabelsClass struct {
App string `json:"app"`
Release string `json:"release"`
}
type Strategy struct {
RollingUpdate RollingUpdate `json:"rollingUpdate"`
Type string `json:"type"`
}
type RollingUpdate struct {
MaxSurge string `json:"maxSurge"`
MaxUnavailable string `json:"maxUnavailable"`
}
type Template struct {
Metadata TemplateMetadata `json:"metadata"`
Spec TemplateSpec `json:"spec"`
}
type TemplateMetadata struct {
CreationTimestamp interface{} `json:"creationTimestamp"`
Labels MatchLabelsClass `json:"labels"`
}
type TemplateSpec struct {
Affinity Affinity `json:"affinity"`
Containers []Container `json:"containers"`
DNSPolicy string `json:"dnsPolicy"`
RestartPolicy string `json:"restartPolicy"`
SchedulerName string `json:"schedulerName"`
SecurityContext SecurityContext `json:"securityContext"`
TerminationGracePeriodSeconds int64 `json:"terminationGracePeriodSeconds"`
Volumes []Volume `json:"volumes"`
}
type Affinity struct {
PodAntiAffinity PodAntiAffinity `json:"podAntiAffinity"`
}
type PodAntiAffinity struct {
PreferredDuringSchedulingIgnoredDuringExecution []PreferredDuringSchedulingIgnoredDuringExecution `json:"preferredDuringSchedulingIgnoredDuringExecution"`
}
type PreferredDuringSchedulingIgnoredDuringExecution struct {
PodAffinityTerm PodAffinityTerm `json:"podAffinityTerm"`
Weight int64 `json:"weight"`
}
type PodAffinityTerm struct {
LabelSelector LabelSelector `json:"labelSelector"`
TopologyKey string `json:"topologyKey"`
}
type LabelSelector struct {
MatchExpressions []MatchExpression `json:"matchExpressions"`
}
type MatchExpression struct {
Key string `json:"key"`
Operator string `json:"operator"`
Values []string `json:"values"`
}
type Container struct {
Image string `json:"image"`
ImagePullPolicy string `json:"imagePullPolicy"`
LivenessProbe NessProbe `json:"livenessProbe"`
Name string `json:"name"`
Ports []Port `json:"ports"`
ReadinessProbe NessProbe `json:"readinessProbe"`
Resources Resources `json:"resources"`
TerminationMessagePath string `json:"terminationMessagePath"`
TerminationMessagePolicy string `json:"terminationMessagePolicy"`
VolumeMounts []VolumeMount `json:"volumeMounts"`
}
type NessProbe struct {
FailureThreshold int64 `json:"failureThreshold"`
HTTPGet HTTPGet `json:"httpGet"`
PeriodSeconds int64 `json:"periodSeconds"`
SuccessThreshold int64 `json:"successThreshold"`
TimeoutSeconds int64 `json:"timeoutSeconds"`
}
type HTTPGet struct {
Path string `json:"path"`
Port string `json:"port"`
Scheme string `json:"scheme"`
}
type Port struct {
ContainerPort int64 `json:"containerPort"`
Name string `json:"name"`
Protocol string `json:"protocol"`
}
type Resources struct {
Limits Limits `json:"limits"`
Requests Limits `json:"requests"`
}
type Limits struct {
CPU string `json:"cpu"`
Memory string `json:"memory"`
}
type VolumeMount struct {
MountPath string `json:"mountPath"`
Name string `json:"name"`
}
type SecurityContext struct {
}
type Volume struct {
ConfigMap ConfigMap `json:"configMap"`
Name string `json:"name"`
}
type ConfigMap struct {
DefaultMode int64 `json:"defaultMode"`
Items []Item `json:"items"`
Name string `json:"name"`
}
type Item struct {
Key string `json:"key"`
Path string `json:"path"`
}
type Status struct {
AvailableReplicas int64 `json:"availableReplicas"`
Conditions []Condition `json:"conditions"`
ObservedGeneration int64 `json:"observedGeneration"`
ReadyReplicas int64 `json:"readyReplicas"`
Replicas int64 `json:"replicas"`
UpdatedReplicas int64 `json:"updatedReplicas"`
}
type Condition struct {
LastTransitionTime string `json:"lastTransitionTime"`
LastUpdateTime string `json:"lastUpdateTime"`
Message string `json:"message"`
Reason string `json:"reason"`
Status string `json:"status"`
Type string `json:"type"`
}
# Fetch the deployment using kubectl as json
->% kubectl get deployment xx-homepage -ojson
{
"apiVersion": "extensions/v1beta1",
"kind": "Deployment",
"metadata": {
"annotations": {
"deployment.kubernetes.io/revision": "1"
},
"creationTimestamp": "2018-06-01T10:03:33Z",
"generation": 19,
"labels": {
"app": "homepage",
"chart": "homepage-0.1.0",
"heritage": "Tiller",
"release": "xx"
},
"name": "xx-homepage",
"namespace": "default",
"resourceVersion": "5262225",
"selfLink": "/apis/extensions/v1beta1/namespaces/default/deployments/xx-homepage",
"uid": "0b35c76a-6583-11e8-9845-42010a9c0054"
},
"spec": {
"progressDeadlineSeconds": 600,
"replicas": 3,
"revisionHistoryLimit": 10,
"selector": {
"matchLabels": {
"app": "homepage",
"release": "xx"
}
},
"strategy": {
"rollingUpdate": {
"maxSurge": "25%",
"maxUnavailable": "25%"
},
"type": "RollingUpdate"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app": "homepage",
"release": "xx"
}
},
"spec": {
"affinity": {
"podAntiAffinity": {
"preferredDuringSchedulingIgnoredDuringExecution": [
{
"podAffinityTerm": {
"labelSelector": {
"matchExpressions": [
{
"key": "app",
"operator": "In",
"values": [
"homepage"
]
}
]
},
"topologyKey": "kubernetes.io/hostname"
},
"weight": 100
}
]
}
},
"containers": [
{
"image": "ipedrazas/multicluster:v0.4",
"imagePullPolicy": "Always",
"livenessProbe": {
"failureThreshold": 3,
"httpGet": {
"path": "/",
"port": "http",
"scheme": "HTTP"
},
"periodSeconds": 10,
"successThreshold": 1,
"timeoutSeconds": 1
},
"name": "homepage",
"ports": [
{
"containerPort": 3000,
"name": "http",
"protocol": "TCP"
}
],
"readinessProbe": {
"failureThreshold": 3,
"httpGet": {
"path": "/",
"port": "http",
"scheme": "HTTP"
},
"periodSeconds": 10,
"successThreshold": 1,
"timeoutSeconds": 1
},
"resources": {
"limits": {
"cpu": "240m",
"memory": "256Mi"
},
"requests": {
"cpu": "120m",
"memory": "128Mi"
}
},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"volumeMounts": [
{
"mountPath": "/etc/nginx/conf.d",
"name": "config-nginx"
}
]
}
],
"dnsPolicy": "ClusterFirst",
"restartPolicy": "Always",
"schedulerName": "default-scheduler",
"securityContext": {},
"terminationGracePeriodSeconds": 30,
"volumes": [
{
"configMap": {
"defaultMode": 420,
"items": [
{
"key": "nginx.conf",
"path": "default.conf"
}
],
"name": "xx-homepage"
},
"name": "config-nginx"
}
]
}
}
},
"status": {
"availableReplicas": 3,
"conditions": [
{
"lastTransitionTime": "2018-06-01T10:03:33Z",
"lastUpdateTime": "2018-06-01T10:04:09Z",
"message": "ReplicaSet \"xx-homepage-558f6f4f84\" has successfully progressed.",
"reason": "NewReplicaSetAvailable",
"status": "True",
"type": "Progressing"
},
{
"lastTransitionTime": "2018-06-25T09:42:34Z",
"lastUpdateTime": "2018-06-25T09:42:34Z",
"message": "Deployment has minimum availability.",
"reason": "MinimumReplicasAvailable",
"status": "True",
"type": "Available"
}
],
"observedGeneration": 19,
"readyReplicas": 3,
"replicas": 3,
"updatedReplicas": 3
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment