Skip to content

Commit

Permalink
Merge branch 'master' into feat/add-pat-setting
Browse files Browse the repository at this point in the history
  • Loading branch information
sZma5a committed Mar 14, 2024
2 parents a00355f + 930487a commit 87be877
Show file tree
Hide file tree
Showing 297 changed files with 47,136 additions and 10 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,11 @@ run/piped: CONFIG_FILE ?=
run/piped: INSECURE ?= false
run/piped: LAUNCHER ?= false
run/piped: LOG_ENCODING ?= humanize
run/piped: EXPERIMENTAL ?= false
run/piped:
ifeq ($(LAUNCHER),true)
ifeq ($(EXPERIMENTAL), true)
go run cmd/pipedv1/main.go piped --tools-dir=/tmp/piped-bin --config-file=$(CONFIG_FILE) --insecure=$(INSECURE) --log-encoding=$(LOG_ENCODING)
else ifeq ($(LAUNCHER),true)
go run cmd/launcher/main.go launcher --config-file=$(CONFIG_FILE) --insecure=$(INSECURE) --log-encoding=$(LOG_ENCODING)
else
go run cmd/piped/main.go piped --tools-dir=/tmp/piped-bin --config-file=$(CONFIG_FILE) --insecure=$(INSECURE) --log-encoding=$(LOG_ENCODING)
Expand Down
35 changes: 35 additions & 0 deletions cmd/pipedv1/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2024 The PipeCD 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.

package main

import (
"log"

"github.com/pipe-cd/pipecd/pkg/app/pipedv1/cmd/piped"
"github.com/pipe-cd/pipecd/pkg/cli"
)

func main() {
app := cli.NewApp(
"piped",
"A component that runs inside target environment to execute deployment and report its state.",
)
app.AddCommands(
piped.NewCommand(),
)
if err := app.Run(); err != nil {
log.Fatal(err)
}
}
87 changes: 87 additions & 0 deletions docs/content/en/blog/control-plane-local-docker-compose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
date: 2024-03-14
title: "Control Plane on local by docker-compose"
linkTitle: "Control Plane on local by docker-compose"
weight: 989
description: "This blog shows you how to install a PipeCD Control Plane on local machine easily."
author: Tetsuya Kikuchi ([@t-kikuc](https://github.com/t-kikuc))
---

Currently, you can deploy and operate a PipeCD Control Plane on a Kubernetes cluster or [on Amazon ECS](./control-plane-on-ecs.md).
However, some developers would like to build a Control Plane more easily for introduction or development.
This blog shows you how to install a PipeCD Control Plane on local machine easily.

This blog is for those who would like to:
- begin using PipeCD and experiment its features instantly, including Control Plane and Piped

### Architecture

The general architecture of PipeCD Control Plane is as below.
![](/images/control-plane-components.png)

> Note: See [Architecture Overview](docs/user-guide/managing-controlplane/architecture-overview/) doc for details.
In this blog, you will build a Control Plane by these containers:

- Server: pipecd server
- Ops: pipecd ops
- Cache: Redis
- Data Store: MySQL
- File Store: MinIO

### Installation of Control Plane

1. Get the demo codes from https://github.com/pipe-cd/demo/blob/main/control_plane/docker-compose/

2. Execute the below command for docker-compose.yaml you got in [1.].

```sh
docker-compose up
```

After executing the above command, you will see logs like below if success.

```log
pipecd-server-1 | successfully loaded control-plane configuration
pipecd-server-1 | successfully connected to file store
pipecd-server-1 | successfully connected to data store
pipecd-server-1 | grpc server will be run without tls
pipecd-server-1 | grpc server will be run without tls
pipecd-server-1 | grpc server is running on [::]:9080
pipecd-server-1 | grpc server is running on [::]:9083
pipecd-server-1 | grpc server will be run without tls
pipecd-server-1 | admin server is running on 9085
pipecd-server-1 | grpc server is running on [::]:9081
pipecd-server-1 | start running http server on :9082
```

### To confirm: Access the console of the Control Plane

1. Access http://localhost:8080 on your web browser.

2. Enter a value as below and `CONTINUE`.
- `Project Name`: `control-plane-local`

3. Enter values as below and `LOGIN`.
- `Username`: `hello-pipecd`
- `Password`: `hello-pipecd`

4. You will see the applications page. Success!

![](/images/control-plane-local-console.png)

### Clean up

To clean up the Control Plane, execute the below command.

```sh
docker-compose down
```

> Note: By following commands instead of above one, you can keep data such as Piped or applications on the Control Plane even after restarting/updating the server component.
```sh
# Restart only the server component.
docker-compose rm -fsv pipecd-server
docker-compose up pipecd-server
```
2 changes: 1 addition & 1 deletion docs/content/en/docs-dev/feature-status/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Please note that the phases (Incubating, Alpha, Beta, and Stable) are applied to
| Quick sync deployment for [ECS Service Discovery](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-discovery.html) | Alpha |
| Deployment with a defined pipeline for [ECS Service Discovery](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-discovery.html) | Alpha |
| Support [AWS App Mesh](https://aws.amazon.com/app-mesh/) | Incubating |
| [Plan preview](../user-guide/plan-preview) | Alpha |
| [Plan preview](../user-guide/plan-preview) | Incubating |
| [Manifest attachment](../user-guide/managing-application/manifest-attachment) | Alpha |

## Piped Agent
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/docs-v0.39.x/feature-status/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Please note that the phases (Incubating, Alpha, Beta, and Stable) are applied to
| [Automated configuration drift detection](../user-guide/managing-application/configuration-drift-detection/) | Incubating |
| [Application live state](../user-guide/managing-application/application-live-state/) | Incubating |
| Support [AWS App Mesh](https://aws.amazon.com/app-mesh/) | Incubating |
| [Plan preview](../user-guide/plan-preview) | Alpha |
| [Plan preview](../user-guide/plan-preview) | Incubating |

## Piped Agent

Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/docs-v0.40.x/feature-status/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Please note that the phases (Incubating, Alpha, Beta, and Stable) are applied to
| [Automated configuration drift detection](../user-guide/managing-application/configuration-drift-detection/) | Incubating |
| [Application live state](../user-guide/managing-application/application-live-state/) | Incubating |
| Support [AWS App Mesh](https://aws.amazon.com/app-mesh/) | Incubating |
| [Plan preview](../user-guide/plan-preview) | Alpha |
| [Plan preview](../user-guide/plan-preview) | Incubating |

## Piped Agent

Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/docs-v0.41.x/feature-status/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Please note that the phases (Incubating, Alpha, Beta, and Stable) are applied to
| [Automated configuration drift detection](../user-guide/managing-application/configuration-drift-detection/) | Incubating |
| [Application live state](../user-guide/managing-application/application-live-state/) | Incubating |
| Support [AWS App Mesh](https://aws.amazon.com/app-mesh/) | Incubating |
| [Plan preview](../user-guide/plan-preview) | Alpha |
| [Plan preview](../user-guide/plan-preview) | Incubating |

## Piped Agent

Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/docs-v0.42.x/feature-status/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Please note that the phases (Incubating, Alpha, Beta, and Stable) are applied to
| [Automated configuration drift detection](../user-guide/managing-application/configuration-drift-detection/) | Incubating |
| [Application live state](../user-guide/managing-application/application-live-state/) | Incubating |
| Support [AWS App Mesh](https://aws.amazon.com/app-mesh/) | Incubating |
| [Plan preview](../user-guide/plan-preview) | Alpha |
| [Plan preview](../user-guide/plan-preview) | Incubating |

## Piped Agent

Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/docs-v0.43.x/feature-status/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Please note that the phases (Incubating, Alpha, Beta, and Stable) are applied to
| [Automated configuration drift detection](../user-guide/managing-application/configuration-drift-detection/) | Incubating |
| [Application live state](../user-guide/managing-application/application-live-state/) | Incubating |
| Support [AWS App Mesh](https://aws.amazon.com/app-mesh/) | Incubating |
| [Plan preview](../user-guide/plan-preview) | Alpha |
| [Plan preview](../user-guide/plan-preview) | Incubating |

## Piped Agent

Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/docs-v0.44.x/feature-status/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Please note that the phases (Incubating, Alpha, Beta, and Stable) are applied to
| [Automated configuration drift detection](../user-guide/managing-application/configuration-drift-detection/) | Incubating |
| [Application live state](../user-guide/managing-application/application-live-state/) | Incubating |
| Support [AWS App Mesh](https://aws.amazon.com/app-mesh/) | Incubating |
| [Plan preview](../user-guide/plan-preview) | Alpha |
| [Plan preview](../user-guide/plan-preview) | Incubating |
| [Manifest attachment](../user-guide/managing-application/manifest-attachment) | Alpha |

## Piped Agent
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/docs-v0.45.x/feature-status/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Please note that the phases (Incubating, Alpha, Beta, and Stable) are applied to
| [Automated configuration drift detection](../user-guide/managing-application/configuration-drift-detection/) | Incubating |
| [Application live state](../user-guide/managing-application/application-live-state/) | Incubating |
| Support [AWS App Mesh](https://aws.amazon.com/app-mesh/) | Incubating |
| [Plan preview](../user-guide/plan-preview) | Alpha |
| [Plan preview](../user-guide/plan-preview) | Incubating |
| [Manifest attachment](../user-guide/managing-application/manifest-attachment) | Alpha |

## Piped Agent
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/docs-v0.46.x/feature-status/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Please note that the phases (Incubating, Alpha, Beta, and Stable) are applied to
| Quick sync deployment for [ECS Service Discovery](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-discovery.html) | Alpha |
| Deployment with a defined pipeline for [ECS Service Discovery](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-discovery.html) | Alpha |
| Support [AWS App Mesh](https://aws.amazon.com/app-mesh/) | Incubating |
| [Plan preview](../user-guide/plan-preview) | Alpha |
| [Plan preview](../user-guide/plan-preview) | Incubating |
| [Manifest attachment](../user-guide/managing-application/manifest-attachment) | Alpha |

## Piped Agent
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 80 additions & 0 deletions pkg/app/pipedv1/analysisprovider/http/http.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright 2024 The PipeCD 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.

// Package http provides a way to analyze with http requests.
// This allows you to do smoke tests, load tests and so on, at your leisure.
package http

import (
"context"
"fmt"
"net/http"
"time"

"github.com/pipe-cd/pipecd/pkg/config"
)

const (
ProviderType = "HTTP"
defaultTimeout = 30 * time.Second
)

type Provider struct {
client *http.Client
}

func (p *Provider) Type() string {
return ProviderType
}

func NewProvider(timeout time.Duration) *Provider {
if timeout == 0 {
timeout = defaultTimeout
}
return &Provider{
client: &http.Client{Timeout: timeout},
}
}

// Run sends an HTTP request and then evaluate whether the response is expected one.
func (p *Provider) Run(ctx context.Context, cfg *config.AnalysisHTTP) (bool, string, error) {
req, err := p.makeRequest(ctx, cfg)
if err != nil {
return false, "", err
}

res, err := p.client.Do(req)
if err != nil {
return false, "", err
}
defer res.Body.Close()

if res.StatusCode != cfg.ExpectedCode {
return false, "", fmt.Errorf("unexpected status code %d", res.StatusCode)
}
// TODO: Decide how to check if the body is expected one.
return true, "", nil
}

func (p *Provider) makeRequest(ctx context.Context, cfg *config.AnalysisHTTP) (*http.Request, error) {
req, err := http.NewRequestWithContext(ctx, cfg.Method, cfg.URL, nil)
if err != nil {
return nil, err
}
req.Header = make(http.Header, len(cfg.Headers))
for _, h := range cfg.Headers {
req.Header.Set(h.Key, h.Value)
}
return req, nil
}
47 changes: 47 additions & 0 deletions pkg/app/pipedv1/analysisprovider/log/factory/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2024 The PipeCD 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.

package factory

import (
"fmt"
"os"

"go.uber.org/zap"

"github.com/pipe-cd/pipecd/pkg/app/piped/analysisprovider/log"
"github.com/pipe-cd/pipecd/pkg/app/piped/analysisprovider/log/stackdriver"
"github.com/pipe-cd/pipecd/pkg/config"
"github.com/pipe-cd/pipecd/pkg/model"
)

// NewProvider generates an appropriate provider according to analysis provider config.
func NewProvider(providerCfg *config.PipedAnalysisProvider, logger *zap.Logger) (provider log.Provider, err error) {
switch providerCfg.Type {
case model.AnalysisProviderStackdriver:
cfg := providerCfg.StackdriverConfig
sa, err := os.ReadFile(cfg.ServiceAccountFile)
if err != nil {
return nil, err
}
provider, err = stackdriver.NewProvider(sa)
if err != nil {
return nil, err
}

default:
return nil, fmt.Errorf("any of providers config not found")
}
return provider, nil
}
28 changes: 28 additions & 0 deletions pkg/app/pipedv1/analysisprovider/log/provider.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2024 The PipeCD 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.

package log

import (
"context"
)

// Provider represents a client for log provider which provides logs for analysis.
type Provider interface {
Type() string
// Evaluate runs the given query against the log provider,
// and then checks if there is at least one error log.
// Returns the result reason if non-error occurred.
Evaluate(ctx context.Context, query string) (result bool, reason string, err error)
}
Loading

0 comments on commit 87be877

Please sign in to comment.