Skip to content

Commit 68c354e

Browse files
Cr 565 - uninstall app-proxy (#191)
* install app-proxy ingress * added support to delete app-proxy
1 parent e52c295 commit 68c354e

File tree

8 files changed

+109
-7
lines changed

8 files changed

+109
-7
lines changed

venona/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.29
1+
1.4.30

venonactl/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.29
1+
1.4.30

venonactl/cmd/install-app-proxy.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var installAppProxyCmdOptions struct {
3030
namespace string
3131
context string
3232
}
33+
dockerRegistry string
3334
templateValues []string
3435
templateFileValues []string
3536
templateValueFiles []string
@@ -56,6 +57,7 @@ var installAppProxyCmd = &cobra.Command{
5657
mergeValueStr(templateValuesMap, "Context", &installAppProxyCmdOptions.kube.context)
5758
mergeValueStr(templateValuesMap, "AppProxy.Host", &installAppProxyCmdOptions.host)
5859
mergeValueStr(templateValuesMap, "AppProxy.IngressClass", &installAppProxyCmdOptions.ingressClass)
60+
mergeValueStr(templateValuesMap, "DockerRegistry", &installAppProxyCmdOptions.dockerRegistry)
5961

6062
mergeValueMSI(templateValuesMap, "AppProxy.resources", &installAppProxyCmdOptions.resources)
6163

@@ -73,6 +75,7 @@ var installAppProxyCmd = &cobra.Command{
7375
CodefreshHost: cfAPIHost,
7476
}
7577
s.AppProxy.Resources = installAppProxyCmdOptions.resources
78+
s.DockerRegistry = installAppProxyCmdOptions.dockerRegistry
7679
extendStoreWithKubeClient(lgr)
7780
fillCodefreshAPI(lgr)
7881
fillKubernetesAPI(lgr, installAppProxyCmdOptions.kube.context, installAppProxyCmdOptions.kube.namespace, false)
@@ -103,10 +106,11 @@ func init() {
103106
viper.BindEnv("kube-namespace", "KUBE_NAMESPACE")
104107
viper.BindEnv("kube-context", "KUBE_CONTEXT")
105108
installCommand.AddCommand(installAppProxyCmd)
109+
installAppProxyCmd.Flags().StringVar(&installAppProxyCmdOptions.dockerRegistry, "docker-registry", "", "The prefix for the container registry that will be used for pulling the required components images. Example: --docker-registry=\"docker.io\"")
106110
installAppProxyCmd.Flags().StringVar(&installAppProxyCmdOptions.host, "host", "", "Host name that will be used by the ingress to route traffic to the App-Proxy service")
107111
installAppProxyCmd.Flags().StringVar(&installAppProxyCmdOptions.ingressClass, "ingress-class", "", "The ingress class name that will be used by the App-Proxy ingress. If left empty, the default one will be used")
108112
installAppProxyCmd.Flags().StringVar(&installAppProxyCmdOptions.kube.namespace, "kube-namespace", viper.GetString("kube-namespace"), "Name of the namespace on which venona should be installed [$KUBE_NAMESPACE]")
109113
installAppProxyCmd.Flags().StringVar(&installAppProxyCmdOptions.kube.context, "kube-context-name", viper.GetString("kube-context"), "Name of the kubernetes context on which venona should be installed (default is current-context) [$KUBE_CONTEXT]")
110114
installAppProxyCmd.Flags().StringArrayVarP(&installAppProxyCmdOptions.templateValueFiles, "values", "f", []string{}, "specify values in a YAML file")
111-
115+
installAppProxyCmd.Flags().StringArrayVar(&installAppProxyCmdOptions.templateValues, "set-value", []string{}, "Set values for templates, example: --set-value LocalVolumesDir=/mnt/disks/ssd0/codefresh-volumes")
112116
}

venonactl/cmd/install-runtime.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func init() {
199199
installRuntimeCmd.Flags().StringVar(&installRuntimeCmdOptions.storageClass, "storage-class", "", "Set a name of your custom storage class, note: this will not install volume provisioning components")
200200
installRuntimeCmd.Flags().StringVar(&installRuntimeCmdOptions.dockerRegistry, "docker-registry", "", "The prefix for the container registry that will be used for pulling the required components images. Example: --docker-registry=\"docker.io\"")
201201

202-
installRuntimeCmd.Flags().BoolVar(&installRuntimeCmdOptions.insecure, "insecure", false, "Set to true to disable TLS when comunicating with the codefresh platform")
202+
installRuntimeCmd.Flags().BoolVar(&installRuntimeCmdOptions.insecure, "insecure", false, "Set to true to disable TLS when communicating with the codefresh platform")
203203
installRuntimeCmd.Flags().BoolVar(&installRuntimeCmdOptions.kube.inCluster, "in-cluster", false, "Set flag if venona is been installed from inside a cluster")
204204
installRuntimeCmd.Flags().BoolVar(&installRuntimeCmdOptions.dryRun, "dry-run", false, "Set to true to simulate installation")
205205
installRuntimeCmd.Flags().BoolVar(&installRuntimeCmdOptions.kubernetesRunnerType, "kubernetes-runner-type", false, "Set the runner type to kubernetes (alpha feature)")
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package cmd
2+
3+
import (
4+
"github.com/codefresh-io/venona/venonactl/pkg/store"
5+
6+
"github.com/codefresh-io/venona/venonactl/pkg/plugins"
7+
"github.com/spf13/cobra"
8+
"github.com/spf13/viper"
9+
)
10+
11+
var uninstallAppProxyCmdOptions struct {
12+
kube struct {
13+
context string
14+
namespace string
15+
}
16+
templateValues []string
17+
templateFileValues []string
18+
templateValueFiles []string
19+
}
20+
21+
var uninstallAppProxytCmd = &cobra.Command{
22+
Use: "app-proxy",
23+
Short: "Uninstall Codefresh's App-Proxy component",
24+
Run: func(cmd *cobra.Command, args []string) {
25+
26+
// get valuesMap from --values <values.yaml> --set-value k=v --set-file k=<context-of file>
27+
templateValuesMap, err := templateValuesToMap(
28+
uninstallAppProxyCmdOptions.templateValueFiles,
29+
uninstallAppProxyCmdOptions.templateValues,
30+
uninstallAppProxyCmdOptions.templateFileValues)
31+
if err != nil {
32+
dieOnError(err)
33+
}
34+
// Merge cmd options with template
35+
mergeValueStr(templateValuesMap, "ConfigPath", &kubeConfigPath)
36+
mergeValueStr(templateValuesMap, "CodefreshHost", &cfAPIHost)
37+
mergeValueStr(templateValuesMap, "Namespace", &uninstallAppProxyCmdOptions.kube.namespace)
38+
mergeValueStr(templateValuesMap, "Context", &uninstallAppProxyCmdOptions.kube.context)
39+
40+
s := store.GetStore()
41+
lgr := createLogger("UninstallAppProxy", verbose, logFormatter)
42+
buildBasicStore(lgr)
43+
extendStoreWithKubeClient(lgr)
44+
fillKubernetesAPI(lgr, uninstallAppProxyCmdOptions.kube.context, uninstallAppProxyCmdOptions.kube.namespace, false)
45+
46+
builder := plugins.NewBuilder(lgr)
47+
48+
if cfAPIHost == "" {
49+
cfAPIHost = "https://g.codefresh.io"
50+
}
51+
s.CodefreshAPI = &store.CodefreshAPI{
52+
Host: cfAPIHost,
53+
}
54+
s.AgentAPI = &store.AgentAPI{
55+
Token: "",
56+
Id: "",
57+
}
58+
59+
deleteOptions := &plugins.DeleteOptions{}
60+
deleteOptions.KubeBuilder = getKubeClientBuilder(
61+
uninstallAppProxyCmdOptions.kube.context,
62+
uninstallAppProxyCmdOptions.kube.namespace,
63+
kubeConfigPath,
64+
false)
65+
66+
builder.Add(plugins.AppProxyPluginType)
67+
deleteOptions.ClusterNamespace = uninstallAppProxyCmdOptions.kube.namespace
68+
values := s.BuildValues()
69+
values = mergeMaps(values, templateValuesMap)
70+
for _, p := range builder.Get() {
71+
err := p.Delete(deleteOptions, values)
72+
if err != nil {
73+
dieOnError(err)
74+
}
75+
}
76+
77+
lgr.Info("Deletion of app-proxy is completed")
78+
},
79+
}
80+
81+
func init() {
82+
uninstallCommand.AddCommand(uninstallAppProxytCmd)
83+
viper.BindEnv("kube-namespace", "KUBE_NAMESPACE")
84+
viper.BindEnv("kube-context", "KUBE_CONTEXT")
85+
uninstallAppProxytCmd.Flags().StringVar(&uninstallAppProxyCmdOptions.kube.namespace, "kube-namespace", viper.GetString("kube-namespace"), "Name of the namespace from which the app-proxy should be uninstalled [$KUBE_NAMESPACE]")
86+
uninstallAppProxytCmd.Flags().StringVar(&uninstallAppProxyCmdOptions.kube.context, "kube-context-name", viper.GetString("kube-context"), "Name of the kubernetes context from which the app-proxy should be uninstalled (default is current-context) [$KUBE_CONTEXT]")
87+
uninstallAppProxytCmd.Flags().StringArrayVar(&uninstallAppProxyCmdOptions.templateValues, "set-value", []string{}, "Set values for templates --set-value agentId=12345")
88+
uninstallAppProxytCmd.Flags().StringArrayVar(&uninstallAppProxyCmdOptions.templateFileValues, "set-file", []string{}, "Set values for templates from file")
89+
uninstallAppProxytCmd.Flags().StringArrayVarP(&uninstallAppProxyCmdOptions.templateValueFiles, "values", "f", []string{}, "Specify values in a YAML file")
90+
91+
}

venonactl/example/values-example.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,8 @@ Namespace: r1
149149
# Host: example.com
150150
# IngressClass: nginx
151151
# TLSSecret: cert-secret-name
152-
# PathPrefix: /app-proxy/?(.*) # default is '/'
152+
# PathPrefix: /app-proxy # default is '/'
153153

154-
### Additional annotations that will be set on the ingress definition
154+
## Additional annotations that will be set on the ingress definition
155155
# Annotations:
156-
# nginx.ingress.kubernetes.io/rewrite-target: /$1
157156
# nginx.ingress.kubernetes.io/whitelist-source-range: 123.123.123.123/130

venonactl/pkg/templates/kubernetes/deployment.app-proxy.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ spec:
3838
value: "3000"
3939
- name: CODEFRESH_HOST
4040
value: {{ .CodefreshHost }}
41+
{{ if ne .AppProxy.PathPrefix "" }}
42+
- name: API_PATH_PREFIX
43+
value: {{ .AppProxy.PathPrefix }}
44+
{{ end }}
4145
ports:
4246
- containerPort: 3000
4347
protocol: TCP

venonactl/pkg/templates/kubernetes/templates.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)