Skip to content

Commit 282c916

Browse files
authored
fix: use consistent cert dir between certgen and standalone run (#7351)
* fix: use consistent cert dir between certgen and standalone run Signed-off-by: Takeshi Yoneda <[email protected]>
1 parent 45ef897 commit 282c916

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

internal/cmd/certgen.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"fmt"
1313
"io"
1414
"path"
15-
"path/filepath"
1615

1716
"github.com/spf13/cobra"
1817
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
@@ -42,22 +41,22 @@ const (
4241
// GetCertGenCommand returns the certGen cobra command to be executed.
4342
func GetCertGenCommand() *cobra.Command {
4443
var (
45-
local bool
46-
dataHome string
44+
local bool
45+
configHome string
4746
)
4847

4948
cmd := &cobra.Command{
5049
Use: "certgen",
5150
Short: "Generate Control Plane Certificates",
5251
RunE: func(cmd *cobra.Command, args []string) error {
53-
return certGen(cmd.Context(), cmd.OutOrStdout(), local, dataHome)
52+
return certGen(cmd.Context(), cmd.OutOrStdout(), local, configHome)
5453
},
5554
}
5655

5756
cmd.PersistentFlags().BoolVarP(&local, "local", "l", false,
5857
"Generate all the certificates locally.")
59-
cmd.PersistentFlags().StringVar(&dataHome, "data-home", "",
60-
"Directory for certificates (defaults to ~/.local/share/envoy-gateway)")
58+
cmd.PersistentFlags().StringVar(&configHome, "config-home", "",
59+
"Directory for certificates (defaults to ~/.config/envoy-gateway")
6160
cmd.PersistentFlags().BoolVarP(&overwriteControlPlaneCerts, "overwrite", "o", false,
6261
"Updates the secrets containing the control plane certs.")
6362
cmd.PersistentFlags().BoolVar(&disableTopologyInjector, "disable-topology-injector", false,
@@ -66,7 +65,7 @@ func GetCertGenCommand() *cobra.Command {
6665
}
6766

6867
// certGen generates control plane certificates.
69-
func certGen(ctx context.Context, logOut io.Writer, local bool, dataHome string) error {
68+
func certGen(ctx context.Context, logOut io.Writer, local bool, configHome string) error {
7069
cfg, err := config.New(logOut, io.Discard)
7170
if err != nil {
7271
return err
@@ -92,18 +91,18 @@ func certGen(ctx context.Context, logOut io.Writer, local bool, dataHome string)
9291
return fmt.Errorf("failed to patch webhook: %w", err)
9392
}
9493
} else {
95-
// Use provided dataHome or default
94+
// Use provided configHome or default
9695
hostCfg := &egv1a1.EnvoyGatewayHostInfrastructureProvider{}
97-
if dataHome != "" {
98-
hostCfg.DataHome = &dataHome
96+
if configHome != "" {
97+
hostCfg.ConfigHome = &configHome
9998
}
10099

101100
paths, err := host.GetPaths(hostCfg)
102101
if err != nil {
103102
return fmt.Errorf("failed to determine paths: %w", err)
104103
}
105104

106-
certPath := filepath.Join(paths.DataHome, "certs")
105+
certPath := paths.CertDir("")
107106
log.Info("generated certificates", "path", certPath)
108107

109108
if err = outputCertsForLocal(certPath, certs); err != nil {

site/content/en/latest/tasks/operations/standalone-deployment-mode.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ All runners in Envoy Gateway are using TLS connection, so create these TLS certi
171171
ensure the Envoy Gateway works properly.
172172

173173
```shell
174-
docker run --rm --volume /tmp/envoy-gateway-test:/tmp/envoy-gateway envoyproxy/gateway:{{< helm-version >}} certgen --local --data-home /tmp/envoy-gateway
174+
docker run --rm --volume /tmp/envoy-gateway-test:/tmp/envoy-gateway envoyproxy/gateway:{{< helm-version >}} certgen --local --config-home /tmp/envoy-gateway
175175
```
176176

177177
### Start Envoy Gateway

0 commit comments

Comments
 (0)