Skip to content

Commit

Permalink
Rebased on master; fixed json_output integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Priya Wadhwa committed Jul 21, 2020
2 parents 5c09250 + 6df5d19 commit 8bc875d
Show file tree
Hide file tree
Showing 27 changed files with 739 additions and 274 deletions.
182 changes: 133 additions & 49 deletions .github/workflows/master.yml

Large diffs are not rendered by default.

180 changes: 133 additions & 47 deletions .github/workflows/pr.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cmd/minikube/cmd/node_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var nodeAddCmd = &cobra.Command{
}

if err := node.Add(cc, n, false); err != nil {
_, err := maybeDeleteAndRetry(*cc, n, nil, err)
_, err := maybeDeleteAndRetry(cmd, *cc, n, nil, err)
if err != nil {
exit.WithError("failed to add node", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/node_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var nodeStartCmd = &cobra.Command{

_, err = node.Start(s, false)
if err != nil {
_, err := maybeDeleteAndRetry(*cc, *n, nil, err)
_, err := maybeDeleteAndRetry(cmd, *cc, *n, nil, err)
if err != nil {
node.MaybeExitWithAdvice(err)
exit.WithError("failed to start node", err)
Expand Down
16 changes: 9 additions & 7 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func runStart(cmd *cobra.Command, args []string) {
}
}

kubeconfig, err := startWithDriver(starter, existing)
kubeconfig, err := startWithDriver(cmd, starter, existing)
if err != nil {
node.MaybeExitWithAdvice(err)
exit.WithError("failed to start node", err)
Expand Down Expand Up @@ -279,10 +279,10 @@ func provisionWithDriver(cmd *cobra.Command, ds registry.DriverState, existing *
}, nil
}

func startWithDriver(starter node.Starter, existing *config.ClusterConfig) (*kubeconfig.Settings, error) {
func startWithDriver(cmd *cobra.Command, starter node.Starter, existing *config.ClusterConfig) (*kubeconfig.Settings, error) {
kubeconfig, err := node.Start(starter, true)
if err != nil {
kubeconfig, err = maybeDeleteAndRetry(*starter.Cfg, *starter.Node, starter.ExistingAddons, err)
kubeconfig, err = maybeDeleteAndRetry(cmd, *starter.Cfg, *starter.Node, starter.ExistingAddons, err)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -411,20 +411,22 @@ func showKubectlInfo(kcs *kubeconfig.Settings, k8sVersion string, machineName st
return nil
}

func maybeDeleteAndRetry(cc config.ClusterConfig, n config.Node, existingAddons map[string]bool, originalErr error) (*kubeconfig.Settings, error) {
func maybeDeleteAndRetry(cmd *cobra.Command, existing config.ClusterConfig, n config.Node, existingAddons map[string]bool, originalErr error) (*kubeconfig.Settings, error) {
if viper.GetBool(deleteOnFailure) {
out.WarningT("Node {{.name}} failed to start, deleting and trying again.", out.V{"name": n.Name})
// Start failed, delete the cluster and try again
profile, err := config.LoadProfile(cc.Name)
profile, err := config.LoadProfile(existing.Name)
if err != nil {
out.ErrT(out.Meh, `"{{.name}}" profile does not exist, trying anyways.`, out.V{"name": cc.Name})
out.ErrT(out.Meh, `"{{.name}}" profile does not exist, trying anyways.`, out.V{"name": existing.Name})
}

err = deleteProfile(profile)
if err != nil {
out.WarningT("Failed to delete cluster {{.name}}, proceeding with retry anyway.", out.V{"name": cc.Name})
out.WarningT("Failed to delete cluster {{.name}}, proceeding with retry anyway.", out.V{"name": existing.Name})
}

// Re-generate the cluster config, just in case the failure was related to an old config format
cc := updateExistingConfigFromFlags(cmd, &existing)
var kubeconfig *kubeconfig.Settings
for _, n := range cc.Nodes {
r, p, m, h, err := node.Provision(&cc, &n, n.ControlPlane, false)
Expand Down
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func ClusterFlagValue() string {
// generateClusterConfig generate a config.ClusterConfig based on flags or existing cluster config
func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k8sVersion string, drvName string) (config.ClusterConfig, config.Node, error) {
var cc config.ClusterConfig
if existing != nil { // create profile config first time
if existing != nil {
cc = updateExistingConfigFromFlags(cmd, existing)
} else {
glog.Info("no existing cluster config was found, will generate one from the flags ")
Expand Down
20 changes: 20 additions & 0 deletions deploy/addons/gcp-auth/gcp-auth-ns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2017 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: Namespace
metadata:
name: gcp-auth
labels:
kubernetes.io/minikube-addons: gcp-auth
12 changes: 12 additions & 0 deletions deploy/addons/gcp-auth/gcp-auth-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: gcp-auth
namespace: gcp-auth
spec:
ports:
- port: 443
targetPort: 8443
protocol: TCP
selector:
app: gcp-auth
150 changes: 150 additions & 0 deletions deploy/addons/gcp-auth/gcp-auth-webhook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: minikube-gcp-auth-certs
namespace: gcp-auth
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: minikube-gcp-auth-certs
rules:
- apiGroups:
- ''
resources:
- secrets
verbs:
- list
- get
- create
- apiGroups:
- admissionregistration.k8s.io
resources:
- mutatingwebhookconfigurations
verbs:
- get
- update

---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: minikube-gcp-auth-certs
namespace: metadata
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: minikube-gcp-auth-certs
subjects:
- kind: ServiceAccount
name: minikube-gcp-auth-certs
namespace: gcp-auth
---
apiVersion: batch/v1
kind: Job
metadata:
name: gcp-auth-certs-create
namespace: gcp-auth
spec:
template:
metadata:
name: gcp-auth-certs-create
spec:
serviceAccountName: minikube-gcp-auth-certs
containers:
- name: create
image: jettech/kube-webhook-certgen:v1.3.0
imagePullPolicy: IfNotPresent
args:
- create
- --host=gcp-auth,gcp-auth.gcp-auth,gcp-auth.gcp-auth.svc
- --namespace=gcp-auth
- --secret-name=gcp-auth-certs
restartPolicy: OnFailure
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: gcp-auth
namespace: gcp-auth
spec:
selector:
matchLabels:
app: gcp-auth
template:
metadata:
labels:
app: gcp-auth
kubernetes.io/minikube-addons: gcp-auth
spec:
containers:
- name: gcp-auth
image: gcr.io/k8s-minikube/gcp-auth-webhook:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8443
volumeMounts:
- name: webhook-certs
mountPath: /etc/webhook/certs
readOnly: true
- name: gcp-project
mountPath: /var/lib/minikube/google_cloud_project
readOnly: true
volumes:
- name: webhook-certs
secret:
secretName: gcp-auth-certs
- name: gcp-project
hostPath:
path: /var/lib/minikube/google_cloud_project
type: File
---
apiVersion: batch/v1
kind: Job
metadata:
name: gcp-auth-certs-patch
namespace: gcp-auth
spec:
template:
metadata:
name: gcp-auth-certs-patch
spec:
serviceAccountName: minikube-gcp-auth-certs
containers:
- name: patch
image: jettech/kube-webhook-certgen:v1.3.0
imagePullPolicy: IfNotPresent
args:
- patch
- --secret-name=gcp-auth-certs
- --namespace=gcp-auth
- --patch-validating=false
- --webhook-name=gcp-auth-webhook-cfg
restartPolicy: OnFailure
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: gcp-auth-webhook-cfg
labels:
app: gcp-auth
webhooks:
- name: gcp-auth-mutate.k8s.io
objectSelector:
matchExpressions:
- key: gcp-auth-skip-secret
operator: DoesNotExist
sideEffects: None
admissionReviewVersions: ["v1","v1beta1"]
clientConfig:
service:
name: gcp-auth
namespace: gcp-auth
path: "/mutate"
rules:
- operations: ["CREATE", "UPDATE"]
apiGroups: ["*"]
apiVersions: ["*"]
resources: ["pods"]
scope: "*"
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ require (
github.com/zchee/go-vmnet v0.0.0-20161021174912-97ebf9174097
golang.org/x/build v0.0.0-20190927031335-2835ba2e683f
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
golang.org/x/sys v0.0.0-20200523222454-059865788121
golang.org/x/text v0.3.2
Expand Down
Loading

0 comments on commit 8bc875d

Please sign in to comment.