Skip to content

Commit

Permalink
Fix permissions, move the systemctl file next to the others. (istio#2586
Browse files Browse the repository at this point in the history
)

* Fix permissions, move the systemctl file next to the others.

* Fix issues raised by review.

Move the makefile content to deb directory.
Add a Dockerfile and a target to test that deb installs. Additional
tests in separate PRs.

* Address review feedback

* Rename target to be clear that we build the deb in docker, not build a docker image

* Run fmt - lint errors

* Fix fmt.sh-generated lint error

* Format

* Fix envoy binary

* Update based on review

* Revert 2 accidental changes, will go to different PR
  • Loading branch information
costinm authored and andraxylia committed Jan 23, 2018
1 parent 16e40d7 commit 205f762
Show file tree
Hide file tree
Showing 89 changed files with 294 additions and 155 deletions.
48 changes: 3 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SHELL := /bin/bash
VERSION ?= "0.5.0"

# If GOPATH is not set by the env, set it to a sane value
GOPATH ?= $(shell cd ../../..; pwd)
GOPATH ?= $(shell cd ${ISTIO_GO}/../../..; pwd)
export GOPATH

# If GOPATH is made up of several paths, use the first one for our targets in this Makefile
Expand Down Expand Up @@ -550,50 +550,8 @@ dist: dist-bin

include .circleci/Makefile

.PHONY: docker.sidecar.deb sidecar.deb ${OUT}/istio-sidecar.deb

# Make the deb image using the CI/CD image and docker.
docker.sidecar.deb:
(cd ${TOP}; docker run --rm -u $(shell id -u) -it \
-v ${GO_TOP}:${GO_TOP} \
-w ${PWD} \
-e USER=${USER} \
--entrypoint /usr/bin/make ${CI_HUB}/ci:${CI_VERSION} \
sidecar.deb )

# Create the 'sidecar' deb, including envoy and istio agents and configs.
# This target uses a locally installed 'fpm' - use 'docker.sidecar.deb' to use
# the builder image.
# TODO: consistent layout, possibly /opt/istio-VER/...
sidecar.deb: ${OUT}/istio-sidecar.deb

ISTIO_SIDECAR_SRC=tools/deb/istio-start.sh \
tools/deb/istio-iptables.sh \
tools/deb/istio.service \
security/tools/deb/istio-auth-node-agent.service \
tools/deb/sidecar.env tools/deb/envoy.json

# --iteration 1 adds a "-1" suffix to the version that didn't exist before
${OUT}/istio-sidecar.deb: ${ISTIO_BIN}/envoy ${ISTIO_BIN}/pilot-agent ${ISTIO_BIN}/node_agent ${ISTIO_SIDECAR_SRC}
mkdir -p ${OUT}
fpm -s dir -t deb -n istio-sidecar -p ${OUT}/istio-sidecar.deb --version ${VERSION} -C ${GO_TOP} -f \
--url http://istio.io \
--license Apache \
--vendor istio.io \
--maintainer [email protected] \
--after-install tools/deb/postinst.sh \
--config-files /var/lib/istio/envoy/sidecar.env \
--config-files /var/lib/istio/envoy/envoy.json \
--description "Istio" \
src/istio.io/istio/tools/deb/istio-start.sh=/usr/local/bin/istio-start.sh \
src/istio.io/istio/tools/deb/istio-iptables.sh=/usr/local/bin/istio-iptables/sh \
src/istio.io/istio/tools/deb/istio.service=/lib/systemd/system/istio.service \
src/istio.io/istio/security/tools/deb/istio-auth-node-agent.service=/lib/systemd/system/istio-auth-node-agent.service \
bin/envoy=/usr/local/bin/envoy \
bin/pilot-agent=/usr/local/bin/pilot-agent \
bin/node_agent=/usr/local/istio/bin/node_agent \
src/istio.io/istio/tools/deb/sidecar.env=/var/lib/istio/envoy/sidecar.env \
src/istio.io/istio/tools/deb/envoy.json=/var/lib/istio/envoy/envoy.json
# Building the debian file, docker.istio.deb and istio.deb
include tools/deb/istio.mk

#-----------------------------------------------------------------------------
# Target: e2e tests
Expand Down
2 changes: 2 additions & 0 deletions bin/OWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
approvers:
- sebastienvas
- yutongz
- costin
- rshriram
5 changes: 3 additions & 2 deletions bin/envsetup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@

# Source the file with: ". envsetup.sh"

export TOP=$(cd $(dirname $0)/../../..; pwd)
export TOP=$(cd ../../..; pwd)

# Used in the shell scripts.
export ISTIO_SRC=$TOP
export GOPATH=$TOP
export ISTIO_GO=$GOPATH/src/istio.io/istio
export PATH=${GOPATH}/bin:$PATH

# hub used to push images.
export HUB=${ISTIO_HUB:-grc.io/istio-testing}
Expand Down Expand Up @@ -82,4 +83,4 @@ function stop() {
if [ "$env" == "minikube" ]; then
minikube stop
fi
}
}
4 changes: 2 additions & 2 deletions bin/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ if [ ! -f vendor/envoy-$PROXYVERSION ] ; then
popd
fi

if [ ! -f $GO_TOP/bin/envoy ] ; then
mkdir -p $GO_TOP/bin
if [ ! -f ${ISTIO_BIN}/envoy ] ; then
mkdir -p ${ISTIO_BIN}
# Make sure the envoy binary exists.
cp $ISTIO_GO/vendor/envoy-$PROXYVERSION ${ISTIO_BIN}/envoy
fi
Expand Down
1 change: 0 additions & 1 deletion broker/pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"encoding/json"
"fmt"
"net/http"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"

Expand Down
1 change: 0 additions & 1 deletion broker/pkg/model/config/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package config

import (
"fmt"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"

Expand Down
1 change: 0 additions & 1 deletion broker/pkg/platform/kube/crd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"fmt"
"os"
"time"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
multierror "github.com/hashicorp/go-multierror"
Expand Down
1 change: 0 additions & 1 deletion broker/pkg/server/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package server
import (
"fmt"
"net/http"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
"github.com/gorilla/mux"
Expand Down
1 change: 0 additions & 1 deletion broker/pkg/testing/util/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"fmt"
"testing"
"time"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
"k8s.io/api/core/v1"
Expand Down
3 changes: 1 addition & 2 deletions mixer/pkg/il/evaluator/evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ import (
"errors"
"fmt"
"math/rand"
"reflect"
"strings"
"sync"
"testing"
"time"

"reflect"

pbv "istio.io/api/mixer/v1/config/descriptor"
"istio.io/istio/mixer/pkg/attribute"
pb "istio.io/istio/mixer/pkg/config/proto"
Expand Down
1 change: 1 addition & 0 deletions mixer/pkg/runtime2/handler/signature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"testing"

"github.com/gogo/protobuf/proto"

"istio.io/istio/mixer/pkg/adapter"
"istio.io/istio/mixer/pkg/runtime2/config"
)
Expand Down
3 changes: 1 addition & 2 deletions mixer/pkg/server/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import (
"fmt"
"net"
"net/http"
"time"

"github.com/prometheus/client_golang/prometheus/promhttp"

"time"

"istio.io/istio/pkg/log"
"istio.io/istio/pkg/version"
)
Expand Down
1 change: 1 addition & 0 deletions mixer/test/client/env/mixer_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"time"

"google.golang.org/grpc"

rpc "istio.io/gogo-genproto/googleapis/google/rpc"

mixerpb "istio.io/api/mixer/v1"
Expand Down
3 changes: 1 addition & 2 deletions mixer/tools/codegen/cmd/mixgenbootstrap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import (
"path/filepath"
"strings"

yaml "gopkg.in/yaml.v2"

"github.com/spf13/cobra"
yaml "gopkg.in/yaml.v2"

"istio.io/istio/mixer/tools/codegen/pkg/bootstrapgen"
)
Expand Down
1 change: 0 additions & 1 deletion pilot/adapter/config/crd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package crd
import (
"fmt"
"time"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
multierror "github.com/hashicorp/go-multierror"
Expand Down
1 change: 0 additions & 1 deletion pilot/adapter/config/crd/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"fmt"
"reflect"
"time"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
multierror "github.com/hashicorp/go-multierror"
Expand Down
1 change: 0 additions & 1 deletion pilot/adapter/config/crd/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"io"
"reflect"
"strings"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
1 change: 0 additions & 1 deletion pilot/adapter/config/file/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"sort"
"strings"
"time"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"

Expand Down
1 change: 0 additions & 1 deletion pilot/adapter/config/ingress/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"errors"
"reflect"
"time"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
"k8s.io/api/extensions/v1beta1"
Expand Down
1 change: 0 additions & 1 deletion pilot/adapter/config/ingress/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"fmt"
"strconv"
"strings"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
multierror "github.com/hashicorp/go-multierror"
Expand Down
1 change: 0 additions & 1 deletion pilot/adapter/config/ingress/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"errors"
"fmt"
"os"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
v1 "k8s.io/api/core/v1"
Expand Down
1 change: 0 additions & 1 deletion pilot/adapter/config/ingress/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"os"
"testing"
"time"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
v1 "k8s.io/api/core/v1"
Expand Down
1 change: 0 additions & 1 deletion pilot/cmd/istioctl/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"fmt"
"io"
"os"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
"github.com/spf13/cobra"
Expand Down
1 change: 0 additions & 1 deletion pilot/cmd/istioctl/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package main

import (
"fmt"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
"github.com/spf13/cobra"
Expand Down
1 change: 0 additions & 1 deletion pilot/cmd/pilot-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"os"
"strings"
"time"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
"github.com/golang/protobuf/ptypes"
Expand Down
1 change: 0 additions & 1 deletion pilot/cmd/pilot-discovery/server/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"fmt"
"net"
"net/http"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down
1 change: 0 additions & 1 deletion pilot/cmd/pilot-discovery/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"code.cloudfoundry.org/copilot"
"github.com/davecgh/go-spew/spew"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
durpb "github.com/golang/protobuf/ptypes/duration"
Expand Down
1 change: 0 additions & 1 deletion pilot/cmd/sidecar-initializer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package main

import (
"os"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
multierror "github.com/hashicorp/go-multierror"
Expand Down
1 change: 0 additions & 1 deletion pilot/model/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"strconv"
"strings"
"time"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
"github.com/golang/protobuf/ptypes"
Expand Down
1 change: 0 additions & 1 deletion pilot/platform/consul/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package consul

import (
"time"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
"github.com/hashicorp/consul/api"
Expand Down
1 change: 0 additions & 1 deletion pilot/platform/consul/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package consul
import (
"fmt"
"strings"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
"github.com/hashicorp/consul/api"
Expand Down
1 change: 0 additions & 1 deletion pilot/platform/consul/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"reflect"
"sort"
"time"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
"github.com/hashicorp/consul/api"
Expand Down
1 change: 0 additions & 1 deletion pilot/platform/eureka/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package eureka
import (
"reflect"
"time"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"

Expand Down
1 change: 0 additions & 1 deletion pilot/platform/eureka/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package eureka

import (
"fmt"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"

Expand Down
19 changes: 18 additions & 1 deletion pilot/platform/kube/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,40 @@ package kube
import (
"fmt"
"os"

// TODO(nmittler): Remove this
_ "github.com/golang/glog"
multierror "github.com/hashicorp/go-multierror"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"

"os/user"

"istio.io/istio/pkg/log"

// import GKE cluster authentication plugin
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"

// import OIDC cluster authentication plugin, e.g. for Tectonic
_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
)

// ResolveConfig checks whether to use the in-cluster or out-of-cluster config
func ResolveConfig(kubeconfig string) (string, error) {
// Consistency with kubectl
if kubeconfig == "" {
kubeconfig = os.Getenv("KUBECONFIG")
}
if kubeconfig == "" {
usr, err := user.Current()
if err == nil {
defaultCfg := usr.HomeDir + "/.kube/config"
_, err := os.Stat(kubeconfig)
if err != nil {
kubeconfig = defaultCfg
}
}
}
if kubeconfig != "" {
info, err := os.Stat(kubeconfig)
if err != nil {
Expand Down
Loading

0 comments on commit 205f762

Please sign in to comment.