Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
istio support, remove cert-manager, update tekton
Browse files Browse the repository at this point in the history
  • Loading branch information
Daishan committed Jun 3, 2020
1 parent 0d3b997 commit 9934e14
Show file tree
Hide file tree
Showing 64 changed files with 3,393 additions and 855 deletions.
3 changes: 2 additions & 1 deletion cli/cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (i *Install) Run(ctx *clicontext.CLIContext) error {
"RIO_DEBUG": strconv.FormatBool(i.EnableDebug),
"IMAGE": fmt.Sprintf("%s:%s", constants.ControllerImage, constants.ControllerImageTag),
"RUN_API_VALIDATOR": "\"TRUE\"",
"MESH_MODE": "linkerd",
}
bootstrapStack.WithAnswer(answers)
controllerStack.WithAnswer(answers)
Expand Down Expand Up @@ -293,7 +294,7 @@ func (i *Install) configureNamespace(ctx *clicontext.CLIContext, systemStack *st
var checkFeatures = map[string][]string{
"gloo": {"gateway", "gateway-proxy", "gloo"},
"build": {"buildkitd", "webhook", "tekton-pipelines/tekton-pipelines-webhook", "tekton-pipelines/tekton-pipelines-controller"},
"letsencrypt": {"cert-manager"},
"letsencrypt": {},
"autoscaling": {"autoscaler"},
"linkerd": {"linkerd/linkerd-identity", "linkerd/linkerd-tap", "linkerd/linkerd-sp-validator", "linkerd/linkerd-proxy-injector", "linkerd/linkerd-controller", "linkerd/linkerd-grafana", "linkerd/linkerd-web", "linkerd/linkerd-destination", "linkerd/linkerd-prometheus"},
}
Expand Down
4 changes: 4 additions & 0 deletions cli/cmd/system/viewconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"encoding/json"
"fmt"
"sort"

"github.com/rancher/rio/cli/cmd/edit/edit"
"github.com/rancher/rio/cli/pkg/builder"
Expand Down Expand Up @@ -129,6 +130,9 @@ func (s *Feature) Run(ctx *clicontext.CLIContext) error {
Description: feature.Description,
})
}
sort.Slice(data, func(i, j int) bool {
return data[i].Name < data[j].Name
})
writer := tables.NewFeatures(ctx)
defer writer.TableWriter().Close()
for _, obj := range data {
Expand Down
3 changes: 1 addition & 2 deletions cli/pkg/clicontext/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import (
"io"
"os"

v3 "github.com/rancher/rio/pkg/generated/clientset/versioned/typed/management.cattle.io/v3"

"github.com/pkg/errors"
webhookv1 "github.com/rancher/gitwatcher/pkg/generated/clientset/versioned/typed/gitwatcher.cattle.io/v1"
v1 "github.com/rancher/rio/pkg/apis/admin.rio.cattle.io/v1"
projectv1 "github.com/rancher/rio/pkg/generated/clientset/versioned/typed/admin.rio.cattle.io/v1"
v3 "github.com/rancher/rio/pkg/generated/clientset/versioned/typed/management.cattle.io/v3"
riov1 "github.com/rancher/rio/pkg/generated/clientset/versioned/typed/rio.cattle.io/v1"
"github.com/rancher/wrangler/pkg/apply"
"github.com/rancher/wrangler/pkg/kubeconfig"
Expand Down
2 changes: 1 addition & 1 deletion cli/pkg/tables/builds.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func findRevision(data interface{}) (string, error) {
if !ok {
return "", nil
}
for _, param := range m.Spec.Inputs.Resources[0].ResourceSpec.Params {
for _, param := range m.Spec.Resources.Inputs[0].PipelineResourceBinding.ResourceSpec.Params {
if param.Name == "revision" {
return param.Value, nil
}
Expand Down
18 changes: 18 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ func main() {
Destination: &config.ConfigController.Features,
Value: "autoscaling,build",
},
cli.StringFlag{
Name: "mesh-mode",
Usage: "Specify which mesh-mode to use(linkerd/istio)",
Destination: &config.ConfigController.MeshMode,
Value: "istio",
},
cli.StringFlag{
Name: "gateway-service-name",
Usage: "Specify which external gateway service name",
Destination: &config.ConfigController.Gateway.ServiceName,
Value: "",
},
cli.StringFlag{
Name: "gateway-service-namespace",
Usage: "Specify which external gateway service namespace",
Destination: &config.ConfigController.Gateway.ServiceNamespace,
Value: "",
},
}
app.Flags = append(app.Flags, debug.Flags(&debugConfig)...)
app.Action = run
Expand Down
97 changes: 42 additions & 55 deletions modules/build/controllers/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (
"github.com/rancher/wrangler/pkg/name"
"github.com/rancher/wrangler/pkg/objectset"
"github.com/rancher/wrangler/pkg/relatedresource"
tektonv1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
tektonv1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
resource "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -168,47 +169,56 @@ func (p populator) populateBuild(buildKey, namespace string, build *riov1.ImageB
}

dir, fileName := filepath.Join(build.Context, filepath.Dir(build.Dockerfile)), filepath.Base(build.Dockerfile)
taskrun := constructors.NewTaskRun(namespace, trName, tektonv1alpha1.TaskRun{
taskrun := constructors.NewTaskRun(namespace, trName, tektonv1beta1.TaskRun{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"sidecar.istio.io/inject": "false",
},
Labels: map[string]string{
constants.ContainerLabel: buildKey,
constants.ServiceLabel: svc.Name,
constants.GitCommitLabel: svc.Annotations[constants.GitCommitLabel],
constants.LogTokenLabel: status.BuildLogToken,
},
},
Spec: tektonv1alpha1.TaskRunSpec{
Spec: tektonv1beta1.TaskRunSpec{
ServiceAccountName: sa.Name,
Timeout: timeout,
TaskSpec: &tektonv1alpha1.TaskSpec{
Inputs: &tektonv1alpha1.Inputs{
Params: []tektonv1alpha1.ParamSpec{
TaskSpec: &tektonv1beta1.TaskSpec{
Resources: &tektonv1beta1.TaskResources{
Inputs: []tektonv1beta1.TaskResource{
{
Name: "image",
Type: tektonv1alpha1.ParamTypeString,
Description: "Where to publish the resulting image",
ResourceDeclaration: resource.ResourceDeclaration{
Name: "source",
Type: resource.PipelineResourceTypeGit,
},
},
{
Name: "docker-context",
Type: tektonv1alpha1.ParamTypeString,
Description: "The context of the build",
},
},
Params: []tektonv1beta1.ParamSpec{
{
Name: "image",
Default: &tektonv1beta1.ArrayOrString{
Type: tektonv1beta1.ParamTypeString,
StringVal: ImageName(namespace, buildKey, build),
},
{
Name: "insecure-registry",
Type: tektonv1alpha1.ParamTypeString,
Description: "Whether to use insecure registry",
},
{
Name: "insecure-registry",
Default: &tektonv1beta1.ArrayOrString{
Type: tektonv1beta1.ParamTypeString,
StringVal: strconv.FormatBool(build.PushRegistry == ""),
},
},
Resources: []tektonv1alpha1.TaskResource{
{
ResourceDeclaration: tektonv1alpha1.ResourceDeclaration{
Name: "source",
Type: tektonv1alpha1.PipelineResourceTypeGit,
},
{
Name: "docker-context",
Default: &tektonv1beta1.ArrayOrString{
Type: tektonv1beta1.ParamTypeString,
StringVal: build.Context,
},
},
},
Steps: []tektonv1alpha1.Step{
Steps: []tektonv1beta1.Step{
{
Container: corev1.Container{
Name: "build-and-push",
Expand All @@ -224,45 +234,22 @@ func (p populator) populateBuild(buildKey, namespace string, build *riov1.ImageB
"--progress=plain",
"--frontend=dockerfile.v0",
"--opt", fmt.Sprintf("filename=%s", fileName),
"--local", "context=$(inputs.params.docker-context)",
"--local", "context=$(params.docker-context)",
"--local", fmt.Sprintf("dockerfile=%s", dir),
"--output", "type=image,name=$(inputs.params.image),push=true,registry.insecure=$(inputs.params.insecure-registry)",
"--output", "type=image,name=$(params.image),push=true,registry.insecure=$(params.insecure-registry)",
},
},
},
},
},
Inputs: tektonv1alpha1.TaskRunInputs{
Params: []tektonv1alpha1.Param{
{
Name: "image",
Value: tektonv1alpha1.ArrayOrString{
Type: tektonv1alpha1.ParamTypeString,
StringVal: ImageName(namespace, buildKey, build),
},
},
{
Name: "insecure-registry",
Value: tektonv1alpha1.ArrayOrString{
Type: tektonv1alpha1.ParamTypeString,
StringVal: strconv.FormatBool(build.PushRegistry == ""),
},
},
{
Name: "docker-context",
Value: tektonv1alpha1.ArrayOrString{
Type: tektonv1alpha1.ParamTypeString,
StringVal: build.Context,
},
},
},
Resources: []tektonv1alpha1.TaskResourceBinding{
Resources: &tektonv1beta1.TaskRunResources{
Inputs: []tektonv1beta1.TaskResourceBinding{
{
PipelineResourceBinding: tektonv1alpha1.PipelineResourceBinding{
PipelineResourceBinding: tektonv1beta1.PipelineResourceBinding{
Name: "source",
ResourceSpec: &tektonv1alpha1.PipelineResourceSpec{
Type: tektonv1alpha1.PipelineResourceTypeGit,
Params: []tektonv1alpha1.ResourceParam{
ResourceSpec: &resource.PipelineResourceSpec{
Type: tektonv1beta1.PipelineResourceTypeGit,
Params: []tektonv1beta1.ResourceParam{
{
Name: "url",
Value: build.Repo,
Expand Down
59 changes: 25 additions & 34 deletions modules/build/controllers/stack/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import (
"github.com/rancher/wrangler/pkg/apply"
"github.com/rancher/wrangler/pkg/name"
"github.com/rancher/wrangler/pkg/objectset"
tektonv1alpha1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
tektonv1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
resource "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/rbac/v1"
"k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -44,7 +45,7 @@ func Register(ctx context.Context, rContext *types.Context) error {
rContext.RBAC.Rbac().V1().Role(),
rContext.RBAC.Rbac().V1().RoleBinding(),
),
"BuildDeployed",
"",
"stack-service-build",
p.populate,
nil)
Expand Down Expand Up @@ -142,27 +143,39 @@ func (p populator) populateBuild(stack *riov1.Stack, systemNamespace string, os
rbacs := populateRbac(stack, sa.Name, p.systemNamespace, pod.Name)
os.Add(rbacs...)

build := constructors.NewTaskRun(stack.Namespace, trName, tektonv1alpha1.TaskRun{
build := constructors.NewTaskRun(stack.Namespace, trName, tektonv1beta1.TaskRun{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"stack-name": stack.Name,
"stack-namespace": stack.Namespace,
},
},
Spec: tektonv1alpha1.TaskRunSpec{
Spec: tektonv1beta1.TaskRunSpec{
ServiceAccountName: sa.Name,
TaskSpec: &tektonv1alpha1.TaskSpec{
Inputs: &tektonv1alpha1.Inputs{
Resources: []tektonv1alpha1.TaskResource{
{
ResourceDeclaration: tektonv1alpha1.ResourceDeclaration{
Name: "source",
Type: tektonv1alpha1.PipelineResourceTypeGit,
Resources: &tektonv1beta1.TaskRunResources{
Inputs: []tektonv1beta1.TaskResourceBinding{
{
PipelineResourceBinding: tektonv1beta1.PipelineResourceBinding{
Name: "source",
ResourceSpec: &resource.PipelineResourceSpec{
Type: tektonv1beta1.PipelineResourceTypeGit,
Params: []tektonv1beta1.ResourceParam{
{
Name: "url",
Value: stack.Spec.Build.Repo,
},
{
Name: "revision",
Value: rev,
},
},
},
},
},
},
Steps: []tektonv1alpha1.Step{
},
TaskSpec: &tektonv1beta1.TaskSpec{
Steps: []tektonv1beta1.Step{
{
Container: corev1.Container{
Name: "rio-up",
Expand All @@ -177,28 +190,6 @@ func (p populator) populateBuild(stack *riov1.Stack, systemNamespace string, os
},
},
},
Inputs: tektonv1alpha1.TaskRunInputs{
Resources: []tektonv1alpha1.TaskResourceBinding{
{
PipelineResourceBinding: tektonv1alpha1.PipelineResourceBinding{
Name: "source",
ResourceSpec: &tektonv1alpha1.PipelineResourceSpec{
Type: tektonv1alpha1.PipelineResourceTypeGit,
Params: []tektonv1alpha1.ResourceParam{
{
Name: "url",
Value: stack.Spec.Build.Repo,
},
{
Name: "revision",
Value: rev,
},
},
},
},
},
},
},
},
})
os.Add(build)
Expand Down
1 change: 0 additions & 1 deletion modules/gloo/controller/service/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"

"github.com/rancher/rio/modules/gloo/pkg/vsfactory"

riov1 "github.com/rancher/rio/pkg/apis/rio.cattle.io/v1"
rioadminv1controller "github.com/rancher/rio/pkg/generated/controllers/admin.rio.cattle.io/v1"
riov1controller "github.com/rancher/rio/pkg/generated/controllers/rio.cattle.io/v1"
Expand Down
Loading

0 comments on commit 9934e14

Please sign in to comment.