-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathargo-obj.txt
89 lines (83 loc) · 2.35 KB
/
argo-obj.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package main
import (
"context"
"flag"
"fmt"
"path/filepath"
// appv1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
// appsv1 "k8s.io/api/apps/v1"
// apiv1 "k8s.io/api/core/v1"
// metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
// "k8s.io/client-go/kubernetes"
// "k8s.io/client-go/tools/clientcmd"
// "k8s.io/client-go/util/homedir"
//
// Uncomment to load all auth plugins
// _ "k8s.io/client-go/plugin/pkg/client/auth"
//
// Or uncomment to load specific auth plugins
// _ "k8s.io/client-go/plugin/pkg/client/auth/azure"
// _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
// _ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
// _ "k8s.io/client-go/plugin/pkg/client/auth/openstack"
)
func main() {
// var kubeconfig *string
// if home := homedir.HomeDir(); home != "" {
// kubeconfig = flag.String("kubeconfig", filepath.Join(home, ".kube", "config"), "(optional) absolute path to the kubeconfig file")
// } else {
// kubeconfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
// }
// flag.Parse()
// config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)
// if err != nil {
// panic(err)
// }
// clientset, err := kubernetes.NewForConfig(config)
// if err != nil {
// panic(err)
// }
// sameApp := &appv1.Application{}
// deployment := &appv1.Application{
// ObjectMeta: metav1.ObjectMeta{
// Name: "my-go-app-new",
// },
// Spec: appsv1.DeploymentSpec{
// Replicas: int32Ptr(2),
// Selector: &metav1.LabelSelector{
// MatchLabels: map[string]string{
// "app": "demo",
// },
// },
// Template: apiv1.PodTemplateSpec{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{
// "app": "demo",
// },
// },
// Spec: apiv1.PodSpec{
// Containers: []apiv1.Container{
// {
// Name: "web",
// Image: "nginx:1.12",
// Ports: []apiv1.ContainerPort{
// {
// Name: "http",
// Protocol: apiv1.ProtocolTCP,
// ContainerPort: 80,
// },
// },
// },
// },
// },
// },
// },
// }
// Create Deployment
fmt.Println("Creating deployment...")
result, err := deploymentsClient.Create(context.TODO(), deployment, metav1.CreateOptions{})
if err != nil {
panic(err)
}
fmt.Printf("Created deployment %q.\n", result.GetObjectMeta().GetName())
}